[Twisted-Python] Newbie question

Timothy Fitz TimothyFitz at gmail.com
Mon Sep 11 11:33:40 MDT 2006


On 9/11/06, glyph at divmod.com <glyph at divmod.com> wrote:
> However, as dialtone said, it should be easy enough to write a non-blocking client; twisted's client support is just as good as its server support :)

Of course, sometimes this isn't possible at all (you're embedded in a
closed source application, etc). The general answer is you need
twisted's loop running on another thread or in another process and you
need to make calls across this. A simple way is to spawn the reactor
in a separate thread (IIRC not all reactors are safe to run on a
thread other than the main one, check with someone more knowledgeable)
and use the threadsafe built-in queue to push requests across (you
just do a blocking pop on the "output" queue and you have the blocking
semantics you wish, but this part is optional). This isn't a common
use case for me, so there may be better or built-in ways of doing
this.

To summarize, Glyph and Dialtone are right, if you can rewrite you
definitely should, but if you can't there are ways around it.




More information about the Twisted-Python mailing list