[Twisted-Python] Returning a Deferred as a result from another Deferred

Ryan Fugger rfugger at gmail.com
Sat Oct 6 02:34:45 EDT 2007

On 10/5/07, David Reid <dreid at dreid.org> wrote:
> On Oct 5, 2007, at 7:46 PM, Ryan Fugger wrote:
> > What if I need to return a Deferred from a deferToThread?
> That isn't really a "What if I" question, that's a "Why do you think
> you" question.
> deferToThread is best used for taking uncontrollably blocking APIs
> (preferably C APIs that release GIL) and getting a Deferred back.  I
> personally can not think of a single reason why you would ever take a
> Deferred returning API and shuffle it off to a thread.

See my original email for the specifics.  I receive a command on a
connection, deferToThread for handling, which involves database
access, and then callFromThread to send a message on another
connection, which returns a Deferred that fires when the reply is
received, triggering a reply to the command on the original


More information about the Twisted-Python mailing list