mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-15 22:13:00 +00:00
cleanup with new IOLoop
restarting interrupted IOLoop is unsafe (tornadoweb/tornado#1155).
This commit is contained in:
@@ -10,8 +10,8 @@ import os
|
|||||||
from subprocess import Popen
|
from subprocess import Popen
|
||||||
|
|
||||||
import tornado.httpserver
|
import tornado.httpserver
|
||||||
import tornado.ioloop
|
|
||||||
import tornado.options
|
import tornado.options
|
||||||
|
from tornado.ioloop import IOLoop
|
||||||
from tornado.log import LogFormatter
|
from tornado.log import LogFormatter
|
||||||
from tornado import gen, web
|
from tornado import gen, web
|
||||||
|
|
||||||
@@ -282,7 +282,7 @@ class JupyterHubApp(Application):
|
|||||||
|
|
||||||
# finally stop the loop once we are all cleaned up
|
# finally stop the loop once we are all cleaned up
|
||||||
self.log.info("...done")
|
self.log.info("...done")
|
||||||
tornado.ioloop.IOLoop.instance().stop()
|
IOLoop.instance().stop()
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
"""Start the whole thing"""
|
"""Start the whole thing"""
|
||||||
@@ -292,16 +292,18 @@ class JupyterHubApp(Application):
|
|||||||
http_server = tornado.httpserver.HTTPServer(self.tornado_application)
|
http_server = tornado.httpserver.HTTPServer(self.tornado_application)
|
||||||
http_server.listen(self.hub_port)
|
http_server.listen(self.hub_port)
|
||||||
|
|
||||||
loop = tornado.ioloop.IOLoop.instance()
|
loop = IOLoop.instance()
|
||||||
try:
|
try:
|
||||||
loop.start()
|
loop.start()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("\nInterrupted")
|
print("\nInterrupted")
|
||||||
finally:
|
finally:
|
||||||
# have to start the loop one more time,
|
# have to install/start a new IOLoop briefly,
|
||||||
# to allow for async cleanup code.
|
# to allow for async cleanup code.
|
||||||
loop.add_callback(self.cleanup)
|
IOLoop.clear_instance()
|
||||||
tornado.ioloop.IOLoop.instance().start()
|
cleanup_loop = IOLoop.instance()
|
||||||
|
cleanup_loop.add_callback(self.cleanup)
|
||||||
|
cleanup_loop.start()
|
||||||
|
|
||||||
main = JupyterHubApp.launch_instance
|
main = JupyterHubApp.launch_instance
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user