Skip to content

Commit 066a0c3

Browse files
author
David Koblas
committed
Use a AND instead of an OR to determine if the bits are set on the event
mask. Also, handle some basic error cases in the event bits and twisted callback.
1 parent 326523b commit 066a0c3

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tornado/platform/twisted.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
from twisted.internet.posixbase import PosixReactorBase
3333
from twisted.internet.interfaces import \
3434
IReactorFDSet, IDelayedCall, IReactorTime
35+
from twisted.python import failure
36+
from twisted.internet import error
3537

3638
from zope.interface import implements
3739

@@ -40,6 +42,7 @@
4042
from tornado.stack_context import NullContext
4143
from tornado.ioloop import IOLoop
4244

45+
4346
class TornadoDelayedCall(object):
4447
"""
4548
DelayedCall object for Tornado.
@@ -139,10 +142,15 @@ def wakeUp(self):
139142
# IReactorFDSet
140143
def _invoke_callback(self, fd, events):
141144
(reader, writer) = self._fds[fd]
142-
if events | IOLoop.READ and reader:
145+
if events & IOLoop.READ and reader:
143146
reader.doRead()
144-
if events | IOLoop.WRITE and writer:
147+
if events & IOLoop.WRITE and writer:
145148
writer.doWrite()
149+
if events & IOLoop.ERROR:
150+
if reader:
151+
reader.readConnectionLost(failure.Failure(error.ConnectionLost()))
152+
if writer:
153+
writer.connectionLost(failure.Failure(error.ConnectionLost()))
146154

147155
def addReader(self, reader):
148156
"""

0 commit comments

Comments
 (0)