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

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

merged 4 commits into from
Jun 17, 2021

Conversation

eastonsuo
Copy link
Contributor

usage:
in extensionApp.initialize_handlers:

self.server_app.startup_tasks.append(function)

@Zsailer
Copy link
Member

Zsailer commented Jun 1, 2021

@pumpkindle, can you give us a bit more detail here—maybe an example of why you'd want this?

@eastonsuo
Copy link
Contributor Author

@Zsailer hello, one way of using this is when I want to create a background async_task when ioloop is ready, for example to create and supervisor a suprocess when ioloop is ready.(an extension may use this feature for such things)

as far as I can see it, the ioloop will be waiting for request after jupyter server is started, and can not use ioloop util then.

@Zsailer
Copy link
Member

Zsailer commented Jun 2, 2021

Interesting. Maybe what makes sense here is to expose the self.io_loop attribute earlier in ServerApp’s lifecycle—i.e. in the initialize step before extensions are loaded.

This would mean adding a self.io_loop = ioloop.IOLoop.current() somewhere in initialize() before load_server_extension() is called. Then, any extension could add background tasks to the ioloop before the server is actually started.

@eastonsuo
Copy link
Contributor Author

@Zsailer yes, you're right, expose self.io_loop earlier is a good solution

@Zsailer
Copy link
Member

Zsailer commented Jun 14, 2021

expose self.io_loop earlier is a good solution

@eastonsuo, would you like to update your PR with this fix?

@Zsailer Zsailer added the waiting for author Blocked, waiting for the author label Jun 14, 2021
@codecov-commenter
Copy link

codecov-commenter commented Jun 17, 2021

Codecov Report

❗ No coverage uploaded for pull request base (master@40c477b). Click here to learn what that means.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #531   +/-   ##
=========================================
  Coverage          ?   76.33%           
=========================================
  Files             ?      110           
  Lines             ?     9816           
  Branches          ?     1067           
=========================================
  Hits              ?     7493           
  Misses            ?     1943           
  Partials          ?      380           
Impacted Files Coverage Δ
jupyter_server/pytest_plugin.py 90.76% <100.00%> (ø)
jupyter_server/serverapp.py 64.95% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 40c477b...ed957fc. Read the comment docs.

Copy link
Member

@Zsailer Zsailer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Zsailer Zsailer removed the waiting for author Blocked, waiting for the author label Jun 17, 2021
@Zsailer Zsailer merged commit 450010e into jupyter-server:master Jun 17, 2021
@blink1073 blink1073 added this to the 1.9 milestone Jun 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants