[Twisted-Python] Unused variables in doSelect

Andrew Bennetts andrew-twisted at puzzling.org
Thu Feb 28 19:58:06 EST 2002


This is a minor thing, but...

doSelect has the following comment (in 0.15.2):
             # Since this loop should really be as fast as possible,
             # I'm caching these global attributes so the interpreter
             # will hit them in the local namespace.
             reads=reads,
             writes=writes,
             rhk=reads.has_key,
             whk=writes.has_key):

But rhk and whk are unused.

Further on in the function, it does:
    for selectables, method, dict in ((r, "doRead", reads),
                                      (w,"doWrite", writes)):
        hkm = dict.has_key

I suggest that either the rhk and whk variables are removed for clarity, or
that that for loop becomes:

    for selectables, method, dict, hkm in ((r, "doRead", reads, rhk),
                                           (w,"doWrite", writes, whk)):

Incidentally, the reason why I'm looking at doSelect in the first place is that
something seems to have changed in 0.15.2 (since 0.15.0) that (on Windows at
least) prevents Ctrl-C or Ctrl-Break from interrupting the process immediately
-- it can take up to a minute for it to respond.  I haven't yet figured out
why, there's nothing obvious wrong.  This also applies to stopping it when
running as a Win NT service.  On the other hand, it no longer constantly uses
1% of the cpu even when idle.  I can reproduce this behaviour with
simpleserv.py, so it's not my code causing it :)

I wouldn't mind looking over the cvs history to look for relevant changes, but
the CVSWeb link is missing from the new website.

Regards,

-Andrew.





More information about the Twisted-Python mailing list