comment review

This commit is contained in:
Min RK
2016-12-20 16:41:26 +01:00
parent 72ab8f99ec
commit 3b3bc8224b
2 changed files with 8 additions and 3 deletions

View File

@@ -55,8 +55,11 @@ class Spawner(LoggingConfigurable):
will_resume = Bool(False,
help="""Whether the Spawner will resume on next start
If a Spawner will resume instead of starting anew (e.g. resuming a Docker container),
API tokens in use when the Spawner stops will not be deleted.
Default is False where each launch of the Spawner will be a new instance.
If True, an existing Spawner will resume instead of starting anew
(e.g. resuming a Docker container),
and API tokens in use when the Spawner stops will not be deleted.
"""
)

View File

@@ -235,7 +235,7 @@ class User(HasTraits):
# Handle < 0.7 behavior with a warning, assuming info was stored in db by the Spawner.
self.log.warning("DEPRECATION: Spawner.start should return (ip, port) in JupyterHub >= 0.7")
if spawner.api_token != api_token:
# Spawner re-used an API token, discard the one we just created
# Spawner re-used an API token, discard the unused api_token
orm_token = orm.APIToken.find(self.db, api_token)
if orm_token is not None:
self.db.delete(orm_token)
@@ -321,6 +321,8 @@ class User(HasTraits):
self.db.delete(self.server)
self.server = None
if not spawner.will_resume:
# find and remove the API token if the spawner isn't
# going to re-use it next time
orm_token = orm.APIToken.find(self.db, api_token)
if orm_token:
self.db.delete(orm_token)