[ZODB-Dev] Leaking file descriptors in ZEO tests

Jim Fulton jim at zope.com
Fri Aug 29 08:47:40 EDT 2008


On Aug 27, 2008, at 10:40 AM, Christian Theune wrote:

> Hi,
>
> I located an issue with leaking file descriptors in the ZEO tests and
> have a simple proposal how to fix it. (I can imagine a better way to
> exist but can't see one right now.)
>
> Here's what happens:
>
> - The (single) thread in the client process uses a
>  ManagedClientConnection.
>
> - The __init__ of ManagedClientConnection's super class causes a  
> trigger
>  to be created which will then be replaced with a shared trigger by
>  ManagedClientConnection's __init__.
>
> - Unfortunately at this time the trigger that got temporarily created
>  won't be garbage collected (or at least the file descriptor won't  
> be),
>  as asyncore holds a shared, module-global map of file descriptor
>  numbers to file descriptor objects.
>
> I fixed it for me by explicitly closing the trigger in
> ManagedClientConnection before replacing it with the shared one.
>
> After that, the number of file descriptors used by the test becomes
> stable and my tests for the almost-merged iterator branch can run
> successfully.

Good analysis!

I fixed it by not creating the extra trigger in the first place.  My  
fix is checked in.

Jim

--
Jim Fulton
Zope Corporation




More information about the ZODB-Dev mailing list