[Zope-DB] Thread in ZODB
Andre Meyer
a.meyer at hccnet.nl
Sat Apr 10 04:33:54 EDT 2004
Hi Zopers
Here is a nice challenge, I hope:
I have a multi-threaded Python application that I want to link to Zope.
The idea is to provide a Web interface for viewing and editing the state
of multiple threads running in Python. On thread should be associated
with Zope and act as the "door" between the ZServer and the other threads.
Unfortunately, I do not manage to create a reference to a thread in the
Zope product's main class because the ZODB refuses to add it.
This is the error message when trying to instantiate the product:
Site Error
An error was encountered while publishing this resource.
Error Type: UnpickleableError
Error Value: Cannot pickle <type 'thread.lock'> objects
And this is the code where it goes wrong:
class Zpyse(SimpleFolder):
meta_type = "Zpyse"
manage_options = (
{'label':'Edit', 'action':'manage_main'},
{'label':'View', 'action':'index_html'}
)
index_html = PageTemplateFile('zpt/index_html', globals())
def manage_editZpyse(self, title, REQUEST=None):
"Method to edit Zpyse instances."
self.title = title
if REQUEST is not None:
return self.index_html(self, REQUEST)
def __init__(self, id, title):
# Sender/Receiver Test
print 'init Zpyse'
ams = spyse.getAMS()
* self.za = ams.createThread('ZopeThread', 'ZopeThread', globals())
qa = ams.createThread('Receiver', 'ReceiverThread', globals())
sa = ams.createThread('Sender', 'SenderThread', globals())
* only this goes wrong, the other threads are created (without self.).
Is there anybody with a good idea about how to handle this?
thanks a lot in advance
Andre
--
Dr. Andre P. Meyer http://home.hccnet.nl/a.meyer/
TNO FEL Command & Control and Simulation, http://www.fel.tno.nl/div2/
Delft Cooperation on Intelligent Systems, http://www.decis.nl/
More information about the Zope-DB
mailing list