[Twisted-Python] How to exit a twistd program with a status code ?

Andrew Bennetts andrew at bemusement.org
Fri Sep 24 07:31:18 EDT 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)

I'm not sure that controlling the process exit value really fits nicely
with twistd's purpose, though.


More information about the Twisted-Python mailing list