select() interruption by signal

Fredrik Lundh fredrik at pythonware.com
Mon Oct 11 14:43:46 EDT 1999


Robert Longstaff <spooky at dreamfish.freeserve.co.uk> wrote:
> However I've found that this alarm signal, although being caught 
> successfully by the handler, also interrupts the select() causing the app 
> to bomb out:
> 
> Traceback (innermost last):
>   File "./myapp.py", line 169, in ?
>     inList, outList, specialList = select.select(select_mask, [], [])
> select.error: (4, 'Interrupted system call')
> 
> Is this just a timing thing? Is the select() 'catching' the signal at the 
> same time as the handler or is the signal 'hanging around' longer than it 
> should?
> 
> Is there an option to get the select() to ignore signals or should I trap 
> the exception (and throw it away)? I can't find any more information in the 
> Python manual or man select. I'm using v1.5.1 on Linux.

fwiw, the single unix specification says:

    [EINTR]
    
    The select() function was interrupted before any of the
    selected events occurred and before the timeout interval
    expired. If SA_RESTART has been set for the interrupting
    signal, it is implementation-dependent whether select()
    restarts or returns with [EINTR].

and so does POSIX, I think.

I suppose this means that trapping the exception
is the right thing to do...

</F>

coming soon:
http://www.pythonware.com/people/fredrik/librarybook.htm





More information about the Python-list mailing list