[Twisted-Python] Unused variables in doSelect

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.

Andrew Bennetts wrote:
OK, I figured out what the issue is - glyph changed the selec.tselect() so that it doesn't get a timeout, so it basically freezes until it gets a connection (unless you have a Delayed). Apparently on Windows the select() system call an't be interrupted. Workaround: Add a Delayed with a timeout of 0.01 so the select loop doesn't freeze? Real Solution: Win32 API event loop. Patches accepted.

On Thu, Feb 28, 2002 at 04:00:39AM -0500, Itamar Shtull-Trauring wrote:
Ah! Thank you, that explains it perfectly. Incidentally, I haven't yet tested this under cygwin, I suspect its version of Python would allow select to be interrupted..
Workaround: Add a Delayed with a timeout of 0.01 so the select loop doesn't freeze?
Hmm, 0.5 or 1 is plenty for what I need.
Real Solution: Win32 API event loop. Patches accepted.
Heh :) I'll look into it, but I'm no Win32 API guru -- maybe it's time I learnt ;). I've looked at win32event module a little before, so I'll see what I can do. -Andrew.

Andrew Bennetts wrote:
OK, I figured out what the issue is - glyph changed the selec.tselect() so that it doesn't get a timeout, so it basically freezes until it gets a connection (unless you have a Delayed). Apparently on Windows the select() system call an't be interrupted. Workaround: Add a Delayed with a timeout of 0.01 so the select loop doesn't freeze? Real Solution: Win32 API event loop. Patches accepted.

On Thu, Feb 28, 2002 at 04:00:39AM -0500, Itamar Shtull-Trauring wrote:
Ah! Thank you, that explains it perfectly. Incidentally, I haven't yet tested this under cygwin, I suspect its version of Python would allow select to be interrupted..
Workaround: Add a Delayed with a timeout of 0.01 so the select loop doesn't freeze?
Hmm, 0.5 or 1 is plenty for what I need.
Real Solution: Win32 API event loop. Patches accepted.
Heh :) I'll look into it, but I'm no Win32 API guru -- maybe it's time I learnt ;). I've looked at win32event module a little before, so I'll see what I can do. -Andrew.
participants (3)
-
Andrew Bennetts
-
Andrew Bennetts
-
Itamar Shtull-Trauring