Skip to content

Commit

Permalink
bugy#105 fixed asyncio issue in tornado 5, when sending script output
Browse files Browse the repository at this point in the history
  • Loading branch information
bugy committed Apr 6, 2018
1 parent 47e5458 commit cf59819
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ def open(self, process_id):
raise Exception("Couldn't find corresponding process")

self.executor = executor
self.ioloop = tornado.ioloop.IOLoop.current()

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

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

tornado.ioloop.IOLoop.current().add_callback(web_socket.close)
web_socket.ioloop.add_callback(web_socket.close)

executor.add_finish_listener(FinishListener())

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

def safe_write(self, message):
if self.ws_connection is not None:
self.write_message(message)
self.ioloop.add_callback(self.write_message, message)


class ScriptExecute(BaseRequestHandler):
Expand Down

0 comments on commit cf59819

Please sign in to comment.