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

David Kao a.libran at gmail.com
Mon Sep 26 06:13:45 MDT 2011


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 at 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 at master1 play]# python fun.py
hello
Process ended

[root at 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 at 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
>




More information about the Twisted-Python mailing list