Update handler events

pull/4/head
Sheng 2017-11-10 17:49:26 +08:00
parent c2ce7d10c4
commit cc1cffe7da
1 changed files with 4 additions and 1 deletions

View File

@ -84,6 +84,9 @@ class Worker(object):
data = data[sent:] data = data[sent:]
if data: if data:
self.data_to_dst.append(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): def close(self):
logging.debug('Closing worker {}'.format(self.id)) logging.debug('Closing worker {}'.format(self.id))
@ -196,7 +199,7 @@ class WsockHandler(tornado.websocket.WebSocketHandler):
self.set_nodelay(True) self.set_nodelay(True)
worker.set_handler(self) worker.set_handler(self)
self.worker_ref = weakref.ref(worker) 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): def on_message(self, message):
logging.debug('"{}" from {}'.format(message, self.src_addr)) logging.debug('"{}" from {}'.format(message, self.src_addr))