Signal SIGINT ignored during socket.accept

James Harris james.harris.1 at gmail.com
Fri Sep 11 13:14:20 EDT 2015


"Grant Edwards" <invalid at invalid.invalid> wrote in message 
news:msum6c$hv$1 at reader1.panix.com...
> On 2015-09-11, Chris Angelico <rosuav at gmail.com> wrote:
>
>> This is what I meant when I said you would be polling. Effectively,
>> you wake up your program every half-second, check if Ctrl-C has been
>> pressed, and if it hasn't, you go back to sleep again. This is pretty
>> inefficient.
>
> Though it offends one's engineering sensibilities[1], it's just not
> that inefficient.

Indeed.

> I'd bet money you won't even be able to measure the
> difference in CPU usage.

You would win your bet.

> Waking up twice per second and immediately
> calling select() again on any hardware/OS built in the past 50 years
> is going completely negligible (as long as you can ignore the smell).

CPU usage is not the only issue but it is a consideration. I tested it 
before posting the code and couldn't see any significant increase in CPU 
use. To give it a better test I have just left running for a couple of 
hours or so. I am pleased to say it currently reports a cumulative total 
of 0:00:00, i.e. it has not clocked up even a second of CPU time yet!

...

> [1] If offenses to engineering sensibility were of concern, then
>    he wouldn't be using Windows in the first place.  ;)

LOL. I know that's tongue in cheek but I tend to favour portability over 
most other things. So running on Windows as well as Unix is, in my book, 
a Good Thing.

James




More information about the Python-list mailing list