[Zope-DB] Thread question
Dieter Maurer
dieter at handshake.de
Thu Jun 24 14:33:40 EDT 2004
Bogdan M. Maryniuck wrote at 2004-6-23 15:26 +0200:
>This is probably wrong maillist, but this is only I can subscribe...
Indeed: "zope at zope.org" would be better...
>Problem:
>I have an object, called "pdfBurner" and I need do in PythonScript
>something like this:
>
>---------------8<------------------
>context.pdfBurner.burn(filename = 'test.pdf')
>return "PDF burner in process"
>---------------8<------------------
>
>This means, you call this PythonScript and it calls burn() method which
>starts separate thread and *immediately* exits to show use the message
>"PDF burner in process". OK, but it works for me only once. Next time
>it sais:
>
>File "/opt/Zope-2.6.2/lib/python/ZODB/Connection.py", line 540, in setstate
> raise RuntimeError(msg)
>RuntimeError: Shouldn't load state for '\x00\x00\x00\x00\x00\x04\xf9\x95' when the connection is closed
This means your thread does not play well with ZODB persistency.
For background, you should read the ZODB3 documentation.
>From it follow the following restrictions:
* each thread must use its own ZODB connection
* do not forget, to close the connection when it is no longer needed
* you must never pass persistent object between threads
Always locate your objects in the thread itself (e.g.
given a path)
* do not forget to commit/abort the transaction before
you close the ZODB connection
--
Dieter
More information about the Zope-DB
mailing list