Fix for the terminal shutdown issue (#4180)

This patch prevents creation of a new terminal when handling websocket handshaking request. The default behavior of `terminado.NamedTermManager` is to automatically start a new terminal in response to a websocket handshake, which prevents a terminal from being properly shut down in JupyterLab as reported in this [issue](jupyterlab/jupyterlab#5061).
This commit is contained in:
Mingxuan Lin 2020-06-07 13:48:11 +02:00 committed by GitHub
parent b5b44eb520
commit 866f4f8e0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,6 +31,8 @@ class TermSocket(WebSocketMixin, IPythonHandler, terminado.TermSocket):
def get(self, *args, **kwargs):
if not self.get_current_user():
raise web.HTTPError(403)
if not args[0] in self.term_manager.terminals:
raise web.HTTPError(404)
return super(TermSocket, self).get(*args, **kwargs)
def on_message(self, message):