select, signals, and "interrupted system call" (EINTR)

Jim Fulton jim@d...
Sun, 01 Oct 2000 10:32:27 -0400

If a select-based (or, presumably, poll-based) server wants to
use signals for anything other than shutdown (e.g. closing and
reopening log files, rereading configs, etc.), then, on some 
platforms, a select call can fail with an "interrupted system
call" (EINTR) error that should be ignored. The asyncore 
main loop should check for this error in it's select call
and the select module should make this error easier to check for.

In Python 1.5.2, the medusa select call can be changed from

r,w,e = (r,w,e, timeout)


while 1:
try: r,w,e = (r,w,e, timeout)
except select.error, v:
if v[0] != EINTR: raise
else: break

I presume that this works in Python 1.6/2.0, but I
haven't tried it yet?

This depends on the structure of select.error values
and requires that we get EINTR from somewhere. (What
should the value be on NT?) 

I wonder if there should be an InterruptedSystemCall
exception somewhere that select raises in this case?

At a minimum, code like the above should be added to 



Jim Fulton mailto:jim@d...
Technical Director (888) 344-4332 Python Powered!
Digital Creations

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission. Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for