[Xapian-discuss] File descriptor leak (?) in Python

Joost Cassee joost at cassee.net
Tue Aug 10 16:35:28 BST 2010


Hi Michel,

On Mon, Aug 9, 2010 at 18:09, Michel Pelletier
<pelletier.michel at gmail.com> wrote:
> Is your code creating database objects in a loop that you are holding
> references to?  If so each object will hold an open fd to various
> database files.  If you don't close or release all references to a
> database then it will not be garbage collected and it's fds will
> remain open.

Your comment have set me on the right track. It is a problem with a
circular reference. I am trying to extract a minimal example, but in
the mean time, how can this happen:

>>> import xapian, weakref, gc
>>> test = Test()
>>> ref = weakref.ref(test)
>>> test = Test()
>>> ref()
<Test object at 0xa16890c>
>>> len(gc.get_referrers(ref()))
1
>>> len(gc.get_referrers(gc.get_referrers(ref())[0]))
1
>>> len(gc.get_referrers(gc.get_referrers(gc.get_referrers(ref())[0])[0]))
1
>>> len(gc.get_referrers(gc.get_referrers(gc.get_referrers(gc.get_referrers(ref())[0])[0])[0]))
1
>>> gc.get_referrers(gc.get_referrers(gc.get_referrers(gc.get_referrers(ref())[0])[0])[0])[0] is ref()
True

I realize that this may no longer be a Xapian issue, but it only seems
to happen with instances holding Xapian objects.

Regards,
Joost

PS. Sorry Michel, if you got this message twice; I sent it to your
address by accident earlier.

--
Joost Cassee
http://joost.cassee.net



More information about the Xapian-discuss mailing list