[ZODB-Dev] ZODB: Are all handles closed?

Christian Reis kiko@async.com.br
Fri, 7 Mar 2003 10:51:17 -0300


On Fri, Mar 07, 2003 at 02:21:07PM +0100, Ulla Theiss wrote:
> We have separated the multiple openings and closings to the following
> code.
> It shows the increasing of the handles clearly.
> 
> Have we forgotten to clear anything or made anything wrong? 
> If not, has anybody an idea, how to fix or work around the problem.
> 
> ----------------------------------snip------snap---------------------
> from ZODB import FileStorage, DB
> 
> for i in range (1,100):
>     storage=FileStorage.FileStorage("TestZODB.fs")
>     db = DB(storage)
>     db.open()
>     print "Open"
>     db.close()
>     print "Close"
>     storage.close()
> ----------------------------------snip------snap---------------------

This could be an fd leak; do you know which handle exactly is being
leaked? /proc is your friend here..

> Enother nice behaviour we can achieve with the following code:
> 
> ----------------------------------snip------snap---------------------
> from ZODB import FileStorage, DB
> 
> storage=FileStorage.FileStorage("TestZODB.fs")
> db = DB(storage)
> 
> for i in range (1,100):
>     db.open()
>     print "Open"
>     db.close()
>     print "Close"
>     storage.close()
> ----------------------------------snip------snap---------------------
> 
> It works about seven times. Then the programm hangs completely.

It's funny that calling db.close() explicitly doesn't free the connection
to be reused in the connection pool, but see my discussion on the same
topic here:

http://mail.zope.org/pipermail/zodb-dev/2003-January/004364.html

At any rate, I'm pretty sure you shouldn't be calling storage.close() if
you want to reuse it the next time the loop runs.

Take care,
--
Christian Reis, Senior Engineer, Async Open Source, Brazil.
http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL