[Twisted-Python] Fast RPC

William Waites ww at groovy.net
Wed Jul 6 12:11:43 EDT 2005

On Wed, Jul 06, 2005 at 11:51:37AM -0400, Itamar Shtull-Trauring wrote:
> On Tue, 2005-07-05 at 23:17 -0400, William Waites wrote:
> > > reactor.run(installSignalHandlers=False) may fix that.
> > 
> > Hmmm. I tried that, but then the reactor stalls. No
> > reactor.callLater's actually seem to get called...
> That's how it's supposed to work: reactor.run() doesn't exit until you
> stop the reactor. You need to setup scheduled calls before running the
> reactor.

I understand that. I had set up a couple of reactor.callLater's
before calling reactor.run(). They just don't actually seem to
get run.

For actual operation, control passes from a thread in the 
C++ method TelEngine::MessageHandler::received(Message &m)
to a python function softswitch.message(m) which then calls
into the reactor using callFromThread. Bit I'm not quite
there yet, first step was to get the reactor running, which
seems to work with threadedselectreactor.

Incidentally, I am running the standard reactor like so in
the block of code that runs when the Yate module is imported
after it initializes the interpreter:

from threading import Thread
t = Thread(target = reactor.run, kwargs = {'installSignalHandlers' : False})

This is necessary because the Yate module's initialization 
method is expected to return. But is this expected to work
in your experience?

Alternatively the Yate module could run the main interpreter in
a separate thread itself that is not expected to return. This
is what the (corresponding) asterisk module does. That might be the
best way, but then it assumes a main-thread function in python
does not return, which is a nuisance if you want to do something
in the python module without using twisted.


More information about the Twisted-Python mailing list