def stop_child(http_server, parent_pid):
"""
Tornado's callback function which checks PID of the parent process.
If PID of the parent process is changed (parent has stopped), will
stop **IOLoop**.
"""
if os.getppid() != parent_pid:
# Stop HTTP server (stop accept new requests)
http_server.stop()
# Stop IOLoop
tornado.ioloop.IOLoop.instance().add_callback(
tornado.ioloop.IOLoop.instance().stop)
评论列表
文章目录