Skip to content

Commit

Permalink
#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 2, 2018
1 parent 519edfd commit 5b260c2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import tornado.ioloop
import tornado.web
import tornado.websocket

from auth.tornado_auth import TornadoAuth
from execution.executor import ScriptExecutor
from execution.logging import ScriptOutputLogger
Expand Down Expand Up @@ -246,6 +245,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 @@ -283,7 +283,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 @@ -299,7 +299,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 5b260c2

Please sign in to comment.