Skip to content

Commit

Permalink
Restore test helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
andfoy committed Jun 1, 2018
1 parent 3ba3f9a commit f37cb8c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion spyder_terminal/server/common.py
Expand Up @@ -11,7 +11,7 @@ def create_app(shell, close_future=None):
"""Create and return a tornado Web Application instance."""
settings = {"static_path": os.path.join(
os.path.dirname(__file__), "static")}
application = tornado.web.Application(routes.ROUTES,
application = tornado.web.Application(routes.gen_routes(close_future),
debug=True,
serve_traceback=True,
autoreload=True, **settings)
Expand Down
13 changes: 8 additions & 5 deletions spyder_terminal/server/logic/term_manager.py
Expand Up @@ -59,11 +59,14 @@ def client_disconnected(self, pid, socket):
self.log.info("Websocket closed, sending SIGHUP to terminal.")
term = self.consoles[pid]
term.clients.remove(socket)
if WINDOWS:
term.kill()
self.pty_read(term.ptyproc.fd)
return
term.killpg(signal.SIGHUP)
try:
if WINDOWS:
term.kill()
self.pty_read(term.ptyproc.fd)
return
term.killpg(signal.SIGHUP)
except OSError:
pass
del self.consoles[pid]

@tornado.gen.coroutine
Expand Down
11 changes: 11 additions & 0 deletions spyder_terminal/server/routes.py
Expand Up @@ -36,3 +36,14 @@
]

ROUTES = REST + WS + WEB


def gen_routes(close_future):
"""Return a list of HTML redirection routes."""
if close_future is not None:
ws = []
for route in WS:
ws.append((route[0], route[1],
dict(close_future=close_future)))
return REST + ws + WEB
return ROUTES
1 change: 1 addition & 0 deletions spyder_terminal/server/websockets/term_ws.py
Expand Up @@ -40,4 +40,5 @@ def on_pty_read(self, text):
self.write_message(text)

def on_pty_died(self):
"""Close websocket if terminal was closed externally."""
self.close()

0 comments on commit f37cb8c

Please sign in to comment.