Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable a way to run a task when an io_loop is created #531

Merged
merged 4 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jupyter_server/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def client_fetch(*parts, headers={}, params={}, **kwargs):


@pytest.fixture
def jp_ws_fetch(jp_serverapp, jp_auth_header, jp_http_port, jp_base_url):
def jp_ws_fetch(jp_serverapp, http_server_client, jp_auth_header, jp_http_port, jp_base_url):
"""Sends a websocket request to a test server.

The fixture is a factory; it can be called like
Expand Down
6 changes: 5 additions & 1 deletion jupyter_server/serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2052,6 +2052,7 @@ def initialize(self, argv=None, find_extensions=True, new_httpserver=True, start
self.init_webapp()
self.init_terminals()
self.init_signal()
self.init_ioloop()
self.load_server_extensions()
self.init_mime_overrides()
self.init_shutdown_no_activity()
Expand Down Expand Up @@ -2331,7 +2332,6 @@ def _cleanup(self):

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

def init_ioloop(self):
"""init self.io_loop so that an extension can use it by io_loop.call_later() to create background tasks"""
self.io_loop = ioloop.IOLoop.current()

def start(self):
""" Start the Jupyter server app, after initialization

Expand Down