The problem is the only objects I need to grab are the ones loaded by
other connections. I use Python's garbage collector to track
references to instances of classes that have been updated. Aside from
the strange error below, the live update functions correctly. It's
almost like the connection is keeping a special cache that's
conflicting with the new objects.


On 7/25/06, Mika, David P (GE, Research) <[EMAIL PROTECTED]> wrote:
I don't know the answer to your question, but when I have separate threads,
I always have each thread independently control their own connection
(open and close).  Perhaps in your situation, you could have the
update function open it's own connection, grab the object in question
from the ZODB, change it, commit it and close.

-----Original Message-----
[mailto:[EMAIL PROTECTED] Behalf Of
Chris S
Sent: Friday, July 21, 2006 6:29 PM
Subject: [ZODB-Dev] Threads and Connections

Is it possible to close a connection used in one thread from another
thread? My program has a locking mechanism, so I can ensure threads
don't use their connection while it's closed, but whenever I try to
close one thread's connection from another thread, I get errors like:

  File "C:\Program
Files\Python24\lib\site-packages\ZODB\", line 252, in
  File "C:\Program
Files\Python24\Lib\site-packages\transaction\", line 169,
in unre
  File "C:\Program Files\Python24\Lib\site-packages\ZODB\",
line 236, in remove
  File "C:\Program Files\Python24\lib\", line 19, in __delitem__
    def __delitem__(self, key): del[key]
KeyError: 26403280

The reason why I'm doing this is because I'm trying to update the
classes of persistent objects loaded into memory. I'm able to load the
new classes just fine, but when I try to close the connection at
program termination, I get the error:

ConnectionStateError: Cannot close a connection joined to a transaction

The only way I'm able to avoid this strange error is if I close all
connections during the update, but since my update function runs in a
different thread, it can't close the connections. Is there a way
around this, or am I misunderstanding something?

For more information about ZODB, see the ZODB Wiki:

ZODB-Dev mailing list  -

For more information about ZODB, see the ZODB Wiki:

ZODB-Dev mailing list  -

Reply via email to