Windows - select.select, timeout and KeyboardInterrupt

Giampaolo RodolĂ  g.rodola at gmail.com
Fri May 7 10:36:44 EDT 2010


You can easily avoid this by setting a lower timeout when calling
asyncore.loop(), like 1 second or less (for example, Twisted uses
0.001 secs).
Actually there's no reason for asyncore to have such a high default
timeout (30 seconds).
I think this should be signaled on the bug tracker.

--- Giampaolo
http://code.google.com/p/pyftpdlib
http://code.google.com/p/psutil


2010/5/6 Paul  Moore <p.f.moore at gmail.com>:
> >From a quick experiment, it seems that select.select with a timeout
> doesn't react to a keyboard interrupt until the timeout expires.
> Specifically, if I do
>
> s = socket.socket()
> select.select([s], [], [], 30)
>
> and then press Ctrl-C, Python waits for the 30 seconds before raising
> KeyboardInterrupt.
>
> Is this a known limitation on Windows? I see no mention of it in the
> documentation. Assuming it is a known limitation, is there a way round
> it? (I'm writing a tiny server using asyncore/asynchat, and the
> delayed response to Ctrl-C is a mild nuisance. Solutions such as "use
> twisted", while probably the sensible option in a wider context, don't
> really apply here - I need something within the confines of the stdlib
> if it's to be worth doing).
>
> Thanks,
> Paul
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list