[Twisted-Python] PB and multiple apps

Andrew Bennetts andrew-twisted at puzzling.org
Fri Feb 14 23:46:41 EST 2003


On Fri, Feb 14, 2003 at 09:55:07PM -0500, Jeff Grimmett wrote:
> 
> 
> > You shouldn't need to be looking at the reactor's 
> > implementation to use PB.
> > 
> > The reactor is Twisted's event loop.  Thus, reactor.stop() 
> > will shutdown your Twisted app.  If you don't want your app 
> > to stop in your callback, don't call reactor.stop() in your callback.
> > 
> > I feel that either you're missing the obvious or I'm 
> > misunderstanding what you're asking.
> 
> You're probably right on both points :-)
> 
> Let me boil this down to essentials. I need a way of creating and
> invoking a one-shot pb client to communicate with a remote object in a
> manner that can be re-used by modules either in an app/rector or modules
> that are functioning outside of an app/reactor.  
> 
> I'm sure I'll figure it out eventually, it's just rough going at the
> moment...

Have you seen doc/examples/pbecho.py and doc/examples/pbechoclient.py?  They
do pretty much exactly this, i.e. a long-running server, and a one-shot
client:

    bash-2.05b$ python pbecho.py
    Saving pbecho application to pbecho-start.tap...
    Saved.
    bash-2.05b$ twistd -f pbecho-start.tap 
    bash-2.05b$ python pbechoclient.py 
    connected.
    Message received: hello world
    error received: pbecho.DefinedError
    Main loop terminated.
    bash-2.05b$ python pbechoclient.py 
    connected.
    Message received: hello world
    error received: pbecho.DefinedError
    Main loop terminated.

(The errors are intentional; see the source)

-Andrew.





More information about the Twisted-Python mailing list