[Twisted-Python] Issue with calling back deferreds from threads

Itamar Shtull-Trauring itamar at itamarst.org
Thu Jul 15 09:53:48 EDT 2004


On Wed, 2004-07-14 at 18:27, Ken Kinder wrote:

> So, in this case, it is desirable (although 
> hackish) to defer the creation of a deferred object to a thread, and 
> itamar's patch prevents this process.

1. Twisted is NOT THREAD SAFE. Code that talks to Twisted in any way
will break if run in a thread in parallel to the main reactor thread.
Use reactor.callFromThread to call Twisted code in the reactor thread
from other threads.

2. Twisted supports non-blocking DNS, see other posts.

3. If you *do* need to connect two Deferreds together, you might want to
look at twisted.internet.defer.maybeDeferred and Deferred.chainDeferred,
functions.

-- 
Itamar Shtull-Trauring    http://itamarst.org






More information about the Twisted-Python mailing list