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

Don't assume empty state means not running #824

Merged
merged 2 commits into from Oct 27, 2016
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 0 additions & 5 deletions jupyterhub/app.py
Expand Up @@ -1058,11 +1058,6 @@ def user_stopped(user):

for orm_user in db.query(orm.User):
self.users[orm_user.id] = user = User(orm_user, self.tornado_settings)
if not user.state:
# without spawner state, server isn't valid
user.server = None
user_summaries.append(_user_summary(user))
continue
self.log.debug("Loading state for %s from db", user.name)
spawner = user.spawner
status = yield spawner.poll()
Expand Down
24 changes: 22 additions & 2 deletions jupyterhub/spawner.py
Expand Up @@ -191,7 +191,7 @@ def __init__(self, **kwargs):
def load_state(self, state):
"""load state from the database

This is the extensible part of state
This is the extensible part of state.

Override in a subclass if there is state to load.
Should call `super`.
Expand Down Expand Up @@ -350,7 +350,27 @@ def stop(self, now=False):
def poll(self):
"""Check if the single-user process is running

return None if it is, an exit status (0 if unknown) if it is not.
returns:

None, if single-user process is running.
Exit status (0 if unknown), if it is not running.

State transitions, behavior, and return response:

- If the Spawner has not been initialized (neither loaded state, nor called start),
it should behave as if it is not running (status=0).
- If the Spawner has not finished starting,
it should behave as if it is running (status=None).

Design assumptions about when `poll` may be called:

- On Hub launch: `poll` may be called before `start` when state is loaded on Hub launch.
`poll` should return exit status 0 (unknown) if the Spawner has not been initialized via
`load_state` or `start`.
- If `.start()` is async: `poll` may be called during any yielded portions of the `start`
process. `poll` should return None when `start` is yielded, indicating that the `start`
process has not yet completed.

"""
raise NotImplementedError("Override in subclass. Must be a Tornado gen.coroutine.")

Expand Down