Re: [Twisted-Python] reactor.stop stops entire twistd

I'm curious what would happen if two separate reactor callLater() methods were executed on two separate functions (we'll call them a() and b()) ... such that a() and b() would be scheduled to run at the same exact moment. How would Twisted handled such a situation? Is there such a thing as callLater() "collision" even if the probability of such collission is quite low? Cheers, Serg
From: Matt Goodall <matt@pollenation.net> Reply-To: Twisted general discussion <twisted-python@twistedmatrix.com> To: Twisted discussion stuff <twisted-python@twistedmatrix.com> Subject: Re: [Twisted-Python] reactor.stop stops entire twistd Date: Wed, 28 Jul 2004 10:15:50 +0100
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@pollenation.net / \__/ \ t: +44 (0)113 2252500 \__/ \__/ / \ Any views expressed are my own and do not necessarily \__/ reflect the views of my employer.
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
_________________________________________________________________ Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail

On Wed, 28 Jul 2004 06:10:00 -0400, Sergio Trejo <serj_trejo@hotmail.com> wrote:
I'm curious what would happen if two separate reactor callLater() methods were executed on two separate functions (we'll call them a() and b()) ... such that a() and b() would be scheduled to run at the same exact moment. How would Twisted handled such a situation? Is there such a thing as callLater() "collision" even if the probability of such collission is quite low?
After some investigating, it seems that, if they were scheduled to be run at precisely the same instant (i.e., their delayedCall.time values were equivalent), they would be run in the order OPPOSITE than the order that the callLater calls happened. There is no "collision", they're just run in sequence. Twisted is not a hard real-time system. :-) -- Twisted | Christopher Armstrong: International Man of Twistery Radix | Release Manager, Twisted Project ---------+ http://radix.twistedmatrix.com

When the callbacks or even spawn process runs in sequence, do they get run till completion before the next one? Christopher Armstrong wrote:
On Wed, 28 Jul 2004 06:10:00 -0400, Sergio Trejo <serj_trejo@hotmail.com> wrote:
I'm curious what would happen if two separate reactor callLater() methods were executed on two separate functions (we'll call them a() and b()) ... such that a() and b() would be scheduled to run at the same exact moment. How would Twisted handled such a situation? Is there such a thing as callLater() "collision" even if the probability of such collission is quite low?
After some investigating, it seems that, if they were scheduled to be run at precisely the same instant (i.e., their delayedCall.time values were equivalent), they would be run in the order OPPOSITE than the order that the callLater calls happened.
There is no "collision", they're just run in sequence. Twisted is not a hard real-time system. :-)
participants (3)
-
Christopher Armstrong
-
Sergio Trejo
-
Tsai Li Ming