Skip to content

Instantly share code, notes, and snippets.

@jason-kane
Created August 28, 2015 17:01
Show Gist options
  • Save jason-kane/18f1516d7c1ef381b35e to your computer and use it in GitHub Desktop.
Save jason-kane/18f1516d7c1ef381b35e to your computer and use it in GitHub Desktop.
hacked up epollreactor for diagnostics
def doPoll(self, timeout):
"""
Poll the poller for new events.
"""
if timeout is None:
timeout = -1 # Wait indefinitely.
try:
# Limit the number of events to the number of io objects we're
# currently tracking (because that's maybe a good heuristic) and
# the amount of time we block to the value specified by our
# caller.
l = self._poller.poll(timeout, len(self._selectables))
except IOError, err:
if err.errno == errno.EINTR:
return
# See epoll_wait(2) for documentation on the other conditions
# under which this can fail. They can only be due to a serious
# programming error on our part, so let's just announce them
# loudly.
raise
_drdw = self._doReadOrWrite
for fd, event in l:
try:
selectable = self._selectables[fd]
except KeyError:
pass
else:
#err = "fd: %r\n event: %r\n IN(read): %r\n OUT(write): %r\n _writes: %r\n _reads: %r\n" % (fd, event, _epoll.EPOLLIN, _epoll.EPOLLOUT, self._writes, self._reads)
#log.msg(err)
if ((event & _epoll.EPOLLIN) and fd not in self._reads):
log.msg('Dropping invalid read event: fd:%r, event:%r' % (fd, event))
log.msg('status: %r\nfstatvfs: %r' % (os.fstat(fd), os.fstatvfs(fd)))
continue
elif ((event & _epoll.EPOLLOUT) and fd not in self._writes):
log.msg('Dropping invalid write event: fd:%r, event:%r' % (fd, event))
log.msg('status: %r\nfstatvfs: %r' % (os.fstat(fd), os.fstatvfs(fd)))
continue
_drdw(selectable, fd, event)
doIteration = doPoll
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment