[Twisted-Python] doWrite called on a twisted.internet.tcp.Port

Jason Kane jason.w.kane at gmail.com
Fri Aug 28 11:23:47 MDT 2015


https://twistedmatrix.com/trac/ticket/4759 -- I tried to post as a
comment in the Trac ticket but "SpamBayes determined spam probability
of 93.78%".

Same issue but w/Linux; I've been hacking around at it for a bit and
found a few things that might be helpful.  I am on old twisted
(12.1.0) using a backported protocols.memcache so this could be
self-inflicted.

Inside epollreactor doPoll() I added sanity checks to log when
_poller.poll() gives us an event flagged for READ on a fd that is
_not_ in self._reads (and similarly with writes).  Low and behold,
gobs of hits.  Unexpected.

So I took a closer look.  It appears to me that _epoll.epoll() is
emitting events that are outside of the flags that epollreactor
carefully registers.  Filtering them out in doPoll seems to avoid this
particular traceback but it also breaks the world.  At least in my
system this appears to be the expected behavior.

So (to restate and summarize) asserting on addWriter() doesn't do
anything because the Port was added by addReader().  Despite only
being in _reads() and being registered with _epoll.EPOLLIN, doPoll()
is getting write events which it happily passes through to
_doReadOrWrite which checks the event flag, sees it as a _POLL_OUT and
tries to write it.

I'll try the obvious (upgrade twisted to current) and see what happens.

[[https://gist.github.com/jason-kane/18f1516d7c1ef381b35e|Gist of my
diagnostic]]



More information about the Twisted-Python mailing list