[Twisted-Python] How to exit a twistd program with a status code ?
Andrew Bennetts
andrew at bemusement.org
Fri Sep 24 05:31:18 MDT 2010
David Cournapeau wrote:
> Hi,
>
> I have a program run through twistd, and would like to exit with a non
> zero status code on some error. I have a callback which stops the
> reactor and then sys.exit(some_value), but twistd still seems to catch
> the SystemExit exception after calling for reactor.stop():
This isn't a good answer, exactly, but it may do the trick...
import os
reactor.addSystemEventTrigger('after', 'shutdown', os._exit, some_value)
reactor.stop()
I'm not sure that controlling the process exit value really fits nicely
with twistd's purpose, though.
-Andrew.
More information about the Twisted-Python
mailing list