Skip to content

Commit

Permalink
Use a AND instead of an OR to determine if the bits are set on the event
Browse files Browse the repository at this point in the history
mask.  Also, handle some basic error cases in the event bits and twisted
callback.
  • Loading branch information
David Koblas committed Oct 25, 2011
1 parent 326523b commit 066a0c3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tornado/platform/twisted.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
from twisted.internet.posixbase import PosixReactorBase
from twisted.internet.interfaces import \
IReactorFDSet, IDelayedCall, IReactorTime
from twisted.python import failure
from twisted.internet import error

from zope.interface import implements

Expand All @@ -40,6 +42,7 @@
from tornado.stack_context import NullContext
from tornado.ioloop import IOLoop


class TornadoDelayedCall(object):
"""
DelayedCall object for Tornado.
Expand Down Expand Up @@ -139,10 +142,15 @@ def wakeUp(self):
# IReactorFDSet
def _invoke_callback(self, fd, events):
(reader, writer) = self._fds[fd]
if events | IOLoop.READ and reader:
if events & IOLoop.READ and reader:
reader.doRead()
if events | IOLoop.WRITE and writer:
if events & IOLoop.WRITE and writer:
writer.doWrite()
if events & IOLoop.ERROR:
if reader:
reader.readConnectionLost(failure.Failure(error.ConnectionLost()))
if writer:
writer.connectionLost(failure.Failure(error.ConnectionLost()))

def addReader(self, reader):
"""
Expand Down

0 comments on commit 066a0c3

Please sign in to comment.