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.

Chris

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.
Dave

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
Chris S
Sent: Friday, July 21, 2006 6:29 PM
To: zodb-dev@zope.org
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:

    self.conn.close()
  File "C:\Program
Files\Python24\lib\site-packages\ZODB\Connection.py", line 252, in
close
    self.transaction_manager.unregisterSynch(self)
  File "C:\Program
Files\Python24\Lib\site-packages\transaction\_manager.py", line 169,
in unre
gisterSynch
    ws.remove(synch)
  File "C:\Program Files\Python24\Lib\site-packages\ZODB\utils.py",
line 236, in remove
    del self.data[id(obj)]
  File "C:\Program Files\Python24\lib\UserDict.py", line 19, in __delitem__
    def __delitem__(self, key): del self.data[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:

transaction.commit()
conn.close()
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?

Chris
_______________________________________________
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev

_______________________________________________
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev

Reply via email to