Skip to content

Commit cf59819

Browse files
committed
#105 fixed asyncio issue in tornado 5, when sending script output
1 parent 47e5458 commit cf59819

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/server.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ def open(self, process_id):
314314
raise Exception("Couldn't find corresponding process")
315315

316316
self.executor = executor
317+
self.ioloop = tornado.ioloop.IOLoop.current()
317318

318319
self.write_message(wrap_to_server_event("input", "your input >>"))
319320

@@ -351,7 +352,7 @@ def finished(self):
351352
except:
352353
LOGGER.exception("Couldn't prepare downloadable files")
353354

354-
tornado.ioloop.IOLoop.current().add_callback(web_socket.close)
355+
web_socket.ioloop.add_callback(web_socket.close)
355356

356357
executor.add_finish_listener(FinishListener())
357358

@@ -363,7 +364,7 @@ def on_close(self):
363364

364365
def safe_write(self, message):
365366
if self.ws_connection is not None:
366-
self.write_message(message)
367+
self.ioloop.add_callback(self.write_message, message)
367368

368369

369370
class ScriptExecute(BaseRequestHandler):

0 commit comments

Comments
 (0)