[Twisted-Python] How to exit a twistd program with a status code ?
exarkun at twistedmatrix.com
exarkun at twistedmatrix.com
Fri Sep 24 08:43:23 EDT 2010
On 11:09 am, ypercube at gmail.com wrote:
>I think that you should not put the sys.exit(1) call, after the
>reactor.stop() call.
>> From my very limited understanding of how Twisted reactor works, it
>>could be
>done with something like:
>
> statusCode = 1 #or whatever
> reactor.stop()
>
>in the method that stops the reactor
>
>and the exit call should be added where (after) the reactor is started:
>
> reactor.run()
> # this will be executed after reactor stops
> sys.exit(statusCode)
>
>Please, correct me if I write nonsense here.
Your understanding seems correct to me. :) This is basically how the
feature would be implemented. Since David is using `twistd` though, he
doesn't get to put extra code after the `reactor.run()` call.
http://twistedmatrix.com/trac/ticket/2182 is a ticket for adding a
feature to `twistd` to make this easier.
Jean-Paul
More information about the Twisted-Python
mailing list