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

Reply via email to