开发者

Make CherryPy exit immediately upon receiving a keyboard interrupt?

Is there an easy way of making CherryPy perform an os._exit(0) once it gets a ^C interrupt?

It would normally wait for all the threads to termina开发者_StackOverflow中文版te which is not useful for debugging as I expect it to shut down immediately.


See https://cherrypy.readthedocs.org/en/3.3.0/refman/process/plugins/signalhandler.html.

handlers = {'SIGTERM': self.bus.exit,
        'SIGHUP': self.handle_SIGHUP,
        'SIGUSR1': self.bus.graceful,
       }

are the default handlers; SIGINT from Ctrl-C isn't there (so I don't know if it's going the same as SIGTERM or what) but you could add it with whatever handler you want, including one that calls sys._exit.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜