mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-15 22:13:00 +00:00
avoid calling Spawner.poll during Spawner.start
moves `spawn_pending` flag to only around start, not the HTTP wait. Some Spawners may not know how to poll until start has finished (DockerSpawner). Let's not require that they do.
This commit is contained in:
@@ -296,16 +296,23 @@ class BaseHandler(RequestHandler):
|
|||||||
yield gen.with_timeout(timedelta(seconds=self.slow_spawn_timeout), f)
|
yield gen.with_timeout(timedelta(seconds=self.slow_spawn_timeout), f)
|
||||||
except gen.TimeoutError:
|
except gen.TimeoutError:
|
||||||
if user.spawn_pending:
|
if user.spawn_pending:
|
||||||
status = yield user.spawner.poll()
|
# still in Spawner.start, which is taking a long time
|
||||||
if status is None:
|
# we shouldn't poll while spawn_pending is True
|
||||||
# hit timeout, but spawn is still pending
|
|
||||||
self.log.warn("User %s server is slow to start", user.name)
|
self.log.warn("User %s server is slow to start", user.name)
|
||||||
# schedule finish for when the user finishes spawning
|
# schedule finish for when the user finishes spawning
|
||||||
IOLoop.current().add_future(f, finish_user_spawn)
|
IOLoop.current().add_future(f, finish_user_spawn)
|
||||||
else:
|
else:
|
||||||
raise web.HTTPError(500, "Spawner failed to start [status=%s]" % status)
|
# start has finished, but the server hasn't come up
|
||||||
|
# check if the server died while we were waiting
|
||||||
|
status = yield user.spawner.poll()
|
||||||
|
if status is None:
|
||||||
|
# hit timeout, but server's running. Hope that it'll show up soon enough,
|
||||||
|
# though it's possible that it started at the wrong URL
|
||||||
|
self.log.warn("User %s server is slow to become responsive", user.name)
|
||||||
|
# schedule finish for when the user finishes spawning
|
||||||
|
IOLoop.current().add_future(f, finish_user_spawn)
|
||||||
else:
|
else:
|
||||||
raise
|
raise web.HTTPError(500, "Spawner failed to start [status=%s]" % status)
|
||||||
else:
|
else:
|
||||||
yield finish_user_spawn()
|
yield finish_user_spawn()
|
||||||
|
|
||||||
|
@@ -206,6 +206,7 @@ class User(HasTraits):
|
|||||||
self.state = spawner.get_state()
|
self.state = spawner.get_state()
|
||||||
self.last_activity = datetime.utcnow()
|
self.last_activity = datetime.utcnow()
|
||||||
db.commit()
|
db.commit()
|
||||||
|
self.spawn_pending = False
|
||||||
try:
|
try:
|
||||||
yield self.server.wait_up(http=True, timeout=spawner.http_timeout)
|
yield self.server.wait_up(http=True, timeout=spawner.http_timeout)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -232,7 +233,6 @@ class User(HasTraits):
|
|||||||
), exc_info=True)
|
), exc_info=True)
|
||||||
# raise original TimeoutError
|
# raise original TimeoutError
|
||||||
raise e
|
raise e
|
||||||
self.spawn_pending = False
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@gen.coroutine
|
@gen.coroutine
|
||||||
|
Reference in New Issue
Block a user