[Twisted-Python] reactor.stop stops entire twistd

Matt Goodall matt at pollenation.net
Wed Jul 28 05:15:50 EDT 2004

On Wed, 2004-07-28 at 09:41, Tsai Li Ming wrote:
> Hi,
> I have the following codes:
> site = server.Site(Core())
> application = service.Application('server')
> sc = service.IServiceCollection(application)
> q = internet.TCPServer(8081, site)
> q.setServiceParent(sc)
> # twistd -y server.tac
> The core class uses methods that uses getProcessOutput, reactor.run aad 
> reactor.stop. However, the whole application gets shutdown because of 
> the reactor.stop.
> How do I avoid having my entire application getting stopped?

Calling reactor.stop() is supposed to shutdown the application (see
below) so please could you explain what you actually wanted to stop by
calling reactor.stop().

In the meantime, here's a couple of points to consider ...

1. The reactor is the event loop for the process and, once running,
*everything* happens because of an event. If you stop the reactor then
you are explicitly telling the reactor to stop processing events and end
the application.

2. twistd manages the creation and activation of the reactor for you (as
well as other useful stuff such as logging). You should not call
reactor.run() in your application.

Cheers, Matt

    /  \__     Matt Goodall, Pollenation Internet Ltd
    \__/  \    w: http://www.pollenation.net
  __/  \__/    e: matt at pollenation.net
 /  \__/  \    t: +44 (0)113 2252500
 \__/  \__/
 /  \          Any views expressed are my own and do not necessarily
 \__/          reflect the views of my employer.

More information about the Twisted-Python mailing list