Skip to content

Commit 450010e

Browse files
authored
enable a way to run a task when an io_loop is created (#531)
* fix jp_ws_fetch not work by its own #441 * add a method for create a task immediately after io_loop is ready * create io_loop earlier to solve 'enable a way to run a task when an io_loop is created #531' Co-authored-by: yi suo <[email protected]>
1 parent 51e3ec3 commit 450010e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

jupyter_server/serverapp.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -2052,6 +2052,7 @@ def initialize(self, argv=None, find_extensions=True, new_httpserver=True, start
20522052
self.init_webapp()
20532053
self.init_terminals()
20542054
self.init_signal()
2055+
self.init_ioloop()
20552056
self.load_server_extensions()
20562057
self.init_mime_overrides()
20572058
self.init_shutdown_no_activity()
@@ -2331,7 +2332,6 @@ def _cleanup(self):
23312332

23322333
def start_ioloop(self):
23332334
"""Start the IO Loop."""
2334-
self.io_loop = ioloop.IOLoop.current()
23352335
if sys.platform.startswith('win'):
23362336
# add no-op to wake every 5s
23372337
# to handle signals that may be ignored by the inner loop
@@ -2344,6 +2344,10 @@ def start_ioloop(self):
23442344
finally:
23452345
self._cleanup()
23462346

2347+
def init_ioloop(self):
2348+
"""init self.io_loop so that an extension can use it by io_loop.call_later() to create background tasks"""
2349+
self.io_loop = ioloop.IOLoop.current()
2350+
23472351
def start(self):
23482352
""" Start the Jupyter server app, after initialization
23492353

0 commit comments

Comments
 (0)