Re: [Twisted-Python] [Twisted] #5272: In the core doc, do not call reactor.stop directly in processEnded

Regarding
The process ''starting'' is different from `ProcessProtocol` methods being called. `ProcessProtocol.processEnded` is ''not'' called until the reactor is running.
On my own VMs, the processEnded gets called
[root@master1 play]# cat fun.py from twisted.internet import reactor
from twisted.internet import reactor, protocol
class OneRun(protocol.ProcessProtocol): def processEnded(self, reason): print "Process ended\n"
reactor.spawnProcess(OneRun(), executable="echo", args=["echo", "hello"], childFDs={0:0, 1:1, 2:2}) [root@master1 play]# python fun.py hello Process ended
[root@master1 play]#
But once again, on a different VM, I only see "hello" and processEnded isn't called.
Both VMs run Python 2.7.1 and Twisted 11.0.0
What is going on?
David Kao
On Mon, Sep 26, 2011 at 8:03 PM, Twisted trac@twistedmatrix.com wrote:
#5272: In the core doc, do not call reactor.stop directly in processEnded ------------------------+--------------------------------------------------- Reporter: dkdog | Owner: Type: defect | Status: closed Priority: normal | Milestone: Component: core | Resolution: worksforme Keywords: | Branch: Branch_author: | Launchpad_bug: ------------------------+--------------------------------------------------- Changes (by exarkun):
* status: reopened => closed * resolution: => worksforme
Comment:
> I just found out that reactor.spawnProcess could spawn the subprocess right away **before** reactor.run is executed.
This doesn't seem related to this ticket.
> I get the impression that most stuff don't get run until the reactor event loop is up and running with reactor.run()
That's true. Most stuff.
> In this case, who's answering all the ProcessProtocol's methods like processEnded then, without an event loop?
The process ''starting'' is different from `ProcessProtocol` methods being called. `ProcessProtocol.processEnded` is ''not'' called until the reactor is running.
Further discussion should be moved to the mailing list. Thanks.
-- Ticket URL: http://twistedmatrix.com/trac/ticket/5272#comment:8 Twisted http://twistedmatrix.com/trac/ Engine of your Internet

On 12:13 pm, a.libran@gmail.com wrote:
Regarding
The process ''starting'' is different from `ProcessProtocol` methods being called. `ProcessProtocol.processEnded` is ''not'' called until the reactor is running.
On my own VMs, the processEnded gets called
[root@master1 play]# cat fun.py from twisted.internet import reactor
from twisted.internet import reactor, protocol
class OneRun(protocol.ProcessProtocol): def processEnded(self, reason): print "Process ended\n"
reactor.spawnProcess(OneRun(), executable="echo", args=["echo", "hello"], childFDs={0:0, 1:1, 2:2}) [root@master1 play]# python fun.py hello Process ended
[root@master1 play]#
But once again, on a different VM, I only see "hello" and processEnded isn't called.
Both VMs run Python 2.7.1 and Twisted 11.0.0
What is going on?
Thanks for this follow-up. I noticed that in this snippet, there's no `reactor.run()� call at all. This is a better example, since it shows `processEnded� being called even though there's no chance of the reactor ever being running. Investigating this, I see that there is an early- exit case in process support (in `twisted/internet/process.py�, line 65) which may call `processEnded� even when the reactor is not running. Inserting a sleep(1) before the `os.waitpid� call in that function makes it much more likely to trigger this case, since it gives the child plenty of time to exit.
This strikes me as a bug. Can you file a new ticket for this?
Thanks again, Jean-Paul
David Kao
On Mon, Sep 26, 2011 at 8:03 PM, Twisted trac@twistedmatrix.com wrote:
#5272: In the core doc, do not call reactor.stop directly in processEnded ------------------------+--------------------------------------------------- � � Reporter: �dkdog � | � � � � � Owner: � � � � Type: �defect �| � � � � �Status: �closed � � Priority: �normal �| � � � Milestone: � �Component: �core � �| � � �Resolution: �worksforme � � Keywords: � � � � �| � � � � �Branch: Branch_author: � � � � �| � Launchpad_bug: ------------------------+--------------------------------------------------- Changes (by exarkun):
�* status: �reopened => closed �* resolution: �=> worksforme
Comment:
�> I just found out that reactor.spawnProcess could spawn the subprocess �right away **before** reactor.run is executed.
�This doesn't seem related to this ticket.
�> I get the impression that most stuff don't get run until the reactor �event loop is up and running with reactor.run()
�That's true. �Most stuff.
�> In this case, who's answering all the ProcessProtocol's methods like �processEnded then, without an event loop?
�The process ''starting'' is different from `ProcessProtocol` methods being �called. �`ProcessProtocol.processEnded` is ''not'' called until the �reactor is running.
�Further discussion should be moved to the mailing list. �Thanks.
-- Ticket URL: http://twistedmatrix.com/trac/ticket/5272#comment:8 Twisted http://twistedmatrix.com/trac/ Engine of your Internet
Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

On Sep 26, 2011, at 9:27 AM, exarkun@twistedmatrix.com wrote:
This strikes me as a bug. Can you file a new ticket for this?
Since we didn't hear back about this, I filed http://twistedmatrix.com/trac/ticket/5287.

My bad. I filed
http://twistedmatrix.com/trac/ticket/5274
You can close either.
David Kao
On Fri, Sep 30, 2011 at 11:52 AM, Glyph Lefkowitz glyph@twistedmatrix.com wrote:
On Sep 26, 2011, at 9:27 AM, exarkun@twistedmatrix.com wrote:
This strikes me as a bug. Can you file a new ticket for this?
Since we didn't hear back about this, I filed http://twistedmatrix.com/trac/ticket/5287.
Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

OK I marked mine as duplicate. I think yours seem like a better description anyways.
David Kao
On Fri, Sep 30, 2011 at 12:05 PM, David Kao a.libran@gmail.com wrote:
My bad. I filed
http://twistedmatrix.com/trac/ticket/5274
You can close either.
David Kao
On Fri, Sep 30, 2011 at 11:52 AM, Glyph Lefkowitz glyph@twistedmatrix.com wrote:
On Sep 26, 2011, at 9:27 AM, exarkun@twistedmatrix.com wrote:
This strikes me as a bug. Can you file a new ticket for this?
Since we didn't hear back about this, I filed http://twistedmatrix.com/trac/ticket/5287.
Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Wish I'd noticed yours first - thanks for filing it! But yeah, I think my description was a bit more descriptive.
On Sep 30, 2011, at 12:22 AM, David Kao wrote:
OK I marked mine as duplicate. I think yours seem like a better description anyways.
David Kao
On Fri, Sep 30, 2011 at 12:05 PM, David Kao a.libran@gmail.com wrote:
My bad. I filed
http://twistedmatrix.com/trac/ticket/5274
You can close either.
David Kao
On Fri, Sep 30, 2011 at 11:52 AM, Glyph Lefkowitz glyph@twistedmatrix.com wrote:
On Sep 26, 2011, at 9:27 AM, exarkun@twistedmatrix.com wrote:
This strikes me as a bug. Can you file a new ticket for this?
Since we didn't hear back about this, I filed http://twistedmatrix.com/trac/ticket/5287.
Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
participants (3)
-
David Kao
-
exarkun@twistedmatrix.com
-
Glyph Lefkowitz