commit cc1cffe7da4abb4b07db9ba872d522c6401cc4e3
parent c2ce7d10c4b43a12befffa5d790379febd0ad18f
Author: Sheng <webmaster0115@gmail.com>
Date: Fri, 10 Nov 2017 17:49:26 +0800
Update handler events
Diffstat:
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/main.py b/main.py
@@ -84,6 +84,9 @@ class Worker(object):
data = data[sent:]
if data:
self.data_to_dst.append(data)
+ self.loop.update_handler(self.fd, IOLoop.WRITE)
+ else:
+ self.loop.update_handler(self.fd, IOLoop.READ)
def close(self):
logging.debug('Closing worker {}'.format(self.id))
@@ -196,7 +199,7 @@ class WsockHandler(tornado.websocket.WebSocketHandler):
self.set_nodelay(True)
worker.set_handler(self)
self.worker_ref = weakref.ref(worker)
- self.loop.add_handler(worker.fd, worker, IOLoop.READ | IOLoop.WRITE)
+ self.loop.add_handler(worker.fd, worker, IOLoop.READ)
def on_message(self, message):
logging.debug('"{}" from {}'.format(message, self.src_addr))