[Twisted-Python] Synchronous Wrapper for Deferreds

James Y Knight foom at fuhm.net
Sat Mar 19 03:15:58 EST 2005


On Mar 19, 2005, at 12:13 AM, Ken Kinder wrote:
> A day or two ago, I inquired on IRC about making calls from an 
> existing synchronous script. The script is not related to any Twisted 
> activity, so minimal intervention was sort of a goal. Obviously this 
> doesn't work on non-transient objects such as Perspective Broker ones, 
> but here's what I came up with... (See attached) Obviously there is 
> some cleaning up to do, but it demonstrates the idea.
>
> I have three questions: (1) I know this isn't the ideal way to use 
> Twisted, but is there anything inherently problematic about my 
> solution for one-off calls to Twisted. (2) I understand there are 
> problems with running the same reactor twice. What are those problems 
> and is there a recommended work around? (3) Are there any ideas on 
> making a synchronous version of a Perspective Broker client to 
> integrate into existing synchronous applications more easily?

What happened to the idea of starting up a completely normal twisted 
event loop in a different thread and communicating via callFromThread 
and queue objects? That seemed like a relatively elegant way to do it, 
to me, as then you can have many different threads doing synchronousish 
stuff at the same time all using the same twisted event loop.

James





More information about the Twisted-Python mailing list