[ZODB-Dev] Closing ZODB connection

Antonio Beamud Montero antonio.beamud at linkend.com
Fri Oct 31 04:57:04 EST 2003


I have find the problem. As Dieter said, was a problem in my app. A
method open a connection and with the open connection this method calls
other method that open other connection, but when this second method try
to do a commit it hang up. Whit several threads all the server hang up.
Now I do the following:
  
   method_A()
     con = self.db.open()
     ...<process>
     con.close()                         method_B()
     x = self.method_B()    ----------->    con = self.db.open()
     con = self.db.open()                   ...<process>
     ...<process>                           con.close()
     con.close()

Is the correct approach or is better only open in A and close when exit
A? i.e. something like:
   method_A()
      con = self.db.open()
      ...<process>                         method_B()
      x = self.method_B() ---------------      ...<process>
      ...<process>
      con.close()  

Thanks for all and sorry if my questions seems stupid... ;-)


El jue, 30-10-2003 a las 19:12, Dieter Maurer escribió:
> Antonio Beamud Montero wrote at 2003-10-30 16:26 +0100:
>  > I have increased de connection pool and works until reaches the
>  > connections limit. 
>  > I close a connection when it has terminated, but it seems not closed.
>  > I'm very confused with DB, connection and root...
>  > 
>  > If I close a connection, why I can use the root object? 
>  > I don't understand anything... :-(
> 
> Maybe, you should read the ZODB3 documentation?
> 
> "close" works reliably. Are you sure, your "close" is executed?
> 
> You can access "root" even when the connection is closed
> because "root" is an independent Python object.
> The connection is required only to store changes into the
> storage and to fetch on demand objects from the storage.
> 
> When you access an object and it needs the connection and
> the connection is closed, you will get the error message:
> "You should not access a closed connection".
> Indeed, this message is right. You should avoid it...
-- 
Antonio Beamud Montero <antonio.beamud at linkend.com>




More information about the ZODB-Dev mailing list