On 12:13 pm, a.lib...@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 <t...@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

_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to