[Zope] Threading

Bogdan M. Maryniuck bo at bitute.b4net.lt
Tue Jun 29 08:20:47 EDT 2004


Hello.

Does anybody know how to get new ZODB connection in background thread?

Effect I would like to get: user clicks on "OK" button and system
immediately answers him "File in process" (user will not wait until it
finish). After process gets done, it stores result to itself somewhere.

Here is an example how I run thread:

 def run(self, id, djs = []):
     if not self.__is_locked:
         thread = threading.Thread(target = self._run, args = (id, djs,))
         thread.setDaemon(1)
         thread.start()

         thread.join()
 

And self._run() is the method of the same class. The problem is that it
does not deal with Persistence and I got error on Connection.py when it
does setstate(): 

RuntimeError: Shouldn't load state for '\x00\x00\x00\x00\x00\x04\xf9\xf2' when the connection is closed

It raises when I do:

   return xml.dom.minidom.parseString(xmldoc)

What it means -- I know, but I am stuck to solve this... Probably too hot. :)

The questions are:
  1. When setstate() is called exactly?
  2. What exactly I need to do to avoid this problem? And how (some
     example or related code would be perfect).
  3. How to pass current db connection of ZODB to the child thread?
     Actually I mean, what object should receive it and for what?
  4. Does somebody knows good URL to RTFM (to ask less)?
  5. Does somebody already have good code example? (it would be top-perfect and 
     short answer for all these my problems).

Thank anybody for advance!

-- 
暮

I've been in the sun for a week.  I took the bold step of leaving my
laptop at home.  I found only 4K messages pending when I returned.
	-- Keith Packard


More information about the Zope mailing list