开发者

Make CherryPy exit immediately upon receiving a keyboard interrupt?

开发者 https://www.devze.com 2023-03-25 00:19 出处:网络
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 d

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

精彩评论

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