[Twisted-Python] Folding the server into the client?

Itamar Turner-Trauring itamar at itamarst.org
Thu Sep 15 14:48:28 EDT 2011

> Itamar, thanks for the reply.
>> You could create a Python API that looks close enough to the code using
>> xmlrpclib, but just uses direct Python function calls. Depending on your
>> code this may mean you don't actually need the reactor. If you do need a
>> reactor, you could still do it without actually doing xmlrpc queries to
>> yourself. If you run the reactor in a different thread,
>> blockingCallFromThread lets you "wait" on a Deferred from another
>> non-reactor thread, in your case the GUI thread (might block your GUI
>> though).
> Hmm, not sure I understand.  Are you saying that deferreds will "work"
> without having a reactor?    (I'm using inlineCallbacks on all the
> xmlrpc_* methods.)

No. I'm saying that:

1. If your code doesn't depend on the reactor you don't need a reactor.
This is not the the case, so you can ignore it.

2. You don't need to xmlrpc from your process to your own process; just
use method calls. This certainly applies.

3. Since you need a reactor, you can either have reactor in different
thread than wx, and talk back and forth using wx.CallAfter (or whatever
that API is) and reactor.callFromThread... or you can use wxreactor and
then both reactor and wx run in same thread.

More information about the Twisted-Python mailing list