[Twisted-Python] Running callbacks in a non-main thread
bob at redivi.com
Fri Feb 3 19:13:04 EST 2006
On Feb 3, 2006, at 2:29 PM, Gabe Rudy wrote:
> I realize that the point of deferreds is to have process/network
> tasks work on in their own thread and send the results to callback
> in the main thread, but is there away to have a deferred process it's
> callback in a non-main thread?
No, that's not the point of deferreds. A Deferred is just an
object. It doesn't know anything at all about threads, and it sure
as hell doesn't implement any sort of thread safety. All it really
does it encapsulate a call chain.
Technically a Deferred will process its callbacks in the same thread
that callback or errback was invoked in. If you feel the need to do
that, your design is probably fubar though.
... there is *one* function in Twisted that will invoke a callable in
a thread and return a Deferred, but that's hardly a common usage.
More information about the Twisted-Python