Fix uncaught exception in pre_spawn_start

This commit is contained in:
GeorgianaElena
2019-08-14 13:21:13 +03:00
parent 146aec7e0c
commit cbbead3780
2 changed files with 25 additions and 11 deletions

View File

@@ -172,7 +172,19 @@ class SpawnHandler(BaseHandler):
spawner._spawn_future = None
# not running, no form. Trigger spawn and redirect back to /user/:name
f = asyncio.ensure_future(self.spawn_single_user(user, server_name))
await asyncio.wait([f], timeout=1)
done, pending = await asyncio.wait([f], timeout=1)
# If spawn_single_user throws an exception, raise a 500 error
# otherwise it may cause a redirect loop
if f in done:
future, = done
exc = future.exception()
if exc:
raise web.HTTPError(
500,
"Error in Authenticator.pre_spawn_start: %s %s"
% (type(exc).__name__, str(exc)),
)
return
self.redirect(pending_url)
@web.authenticated