[Twisted-Python] Twisted & ZODB

glyph at divmod.com glyph at divmod.com
Fri Nov 11 03:10:18 EST 2005

On Thu, 10 Nov 2005 23:33:51 +0300, Garanin Michael <garanin at m-lan.ru> wrote:

>I am newcomer, and try develop Twisted+ZODB application.
>My questions: What is good practices used Twisted+ZODB? I think my code
>will be 'blocking'(where Deferred-source???) and my client-request
>handler also will be 'blocking'. How do i simple solve
>'blocking'-problem (DeferedToThread,...) ?

deferToThread is probably a reasonable thing to do when writing code to work with ZODB, especially ZODB transactions, since ZODB more or less manages concurrency itself internally.

However, as has been discussed many times on this list, this is a very hard problem.  Do not expect deferToThread to be a "simple solution".

For example: Twisted is not thread safe except where *explicitly* noted, and you should be careful to not call any Twisted methods or functions from within your threaded ZODB code; your responses will all have to be processed and sent to the network through either callFromThread or within the callbacks to the deferreds returned from deferToThread.

More information about the Twisted-Python mailing list