mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-13 04:53:01 +00:00
starting a server updates last_activity and started for user and spawner
This commit is contained in:
@@ -119,16 +119,16 @@ class APIHandler(BaseHandler):
|
||||
if '' in user.spawners:
|
||||
spawner = user.spawners['']
|
||||
model['pending'] = spawner.pending or None
|
||||
if spawner.active and spawner.started:
|
||||
model['started'] = isoformat(spawner.started)
|
||||
if spawner.active and spawner.orm_spawner.started:
|
||||
model['started'] = isoformat(spawner.orm_spawner.started)
|
||||
|
||||
if self.allow_named_servers:
|
||||
servers = model['servers'] = {}
|
||||
for name, spawner in user.spawners.items():
|
||||
last_activity = spawner.orm_spawner.last_activity
|
||||
if last_activity:
|
||||
last_activity = isoformat(last_activity)
|
||||
if spawner.ready:
|
||||
last_activity = spawner.orm_spawner.last_activity
|
||||
if last_activity:
|
||||
last_activity = isoformat(last_activity)
|
||||
servers[name] = s = {
|
||||
'name': name,
|
||||
'last_activity': last_activity,
|
||||
|
@@ -380,7 +380,10 @@ class User:
|
||||
await maybe_future(authenticator.pre_spawn_start(self, spawner))
|
||||
|
||||
spawner._start_pending = True
|
||||
spawner.started = datetime.utcnow()
|
||||
# update spawner start time, and activity for both spawner and user
|
||||
self.last_activity = \
|
||||
spawner.orm_spawner.started = \
|
||||
spawner.orm_spawner.last_activity = datetime.utcnow()
|
||||
db.commit()
|
||||
# wait for spawner.start to return
|
||||
try:
|
||||
@@ -529,7 +532,7 @@ class User:
|
||||
self.db.delete(orm_token)
|
||||
self.db.commit()
|
||||
finally:
|
||||
spawner.started = None
|
||||
spawner.orm_spawner.started = None
|
||||
self.db.commit()
|
||||
# trigger post-spawner hook on authenticator
|
||||
auth = spawner.authenticator
|
||||
|
Reference in New Issue
Block a user