handle KeyError when get session (#6245)

pull/6253/head
ccw630 4 years ago committed by GitHub
parent 601ac0e4f4
commit 46f40e7703
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -189,7 +189,10 @@ class SessionManager(LoggingConfigurable):
raise web.HTTPError(404, u'Session not found: %s' % (', '.join(q)))
model = yield maybe_future(self.row_to_model(row))
try:
model = yield maybe_future(self.row_to_model(row))
except KeyError as e:
raise web.HTTPError(404, u'Session not found: %s' % str(e))
raise gen.Return(model)
@gen.coroutine

@ -94,7 +94,7 @@ class TestSessionManager(TestCase):
session = self.create_session(path='/path/to/1/test1.ipynb', kernel_name='python')
# kill the kernel
sm.kernel_manager.shutdown_kernel(session['kernel']['id'])
with self.assertRaises(KeyError):
with self.assertRaises(web.HTTPError):
self.loop.run_sync(lambda: sm.get_session(session_id=session['id']))
# no sessions left
listed = self.loop.run_sync(lambda: sm.list_sessions())

Loading…
Cancel
Save