Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #5467
| From | Nobody <nobody@nowhere.com> |
|---|---|
| Subject | Re: connect SIGINT to custom interrupt handler |
| Date | 2011-05-16 03:53 +0100 |
| Message-Id | <pan.2011.05.16.02.52.43.390000@nowhere.com> |
| Newsgroups | comp.lang.python |
| References | <slrnisv835.b74.chris@scheingraber.no-ip.org> <pan.2011.05.15.13.08.22.15000@nowhere.com> <slrnisvove.dj0.chris@scheingraber.no-ip.org> |
| Organization | Zen Internet |
On Sun, 15 May 2011 14:32:13 +0000, Christoph Scheingraber wrote:
> I now have signal.siginterrupt(signal.SIGINT, False) in the line
> below signal.signal(signal.SIGINT, interrupt_handler)
>
> Unfortunately, pressing ^c still results in the same interrupt error.
Sorry; I wasn't paying sufficient attention to the details:
>>> select.error: (4, 'Interrupted system call')
According to Linux' signal(7) manpage, select() is never restarted,
regardless of the siginterrupt() setting.
In general, wait-for-something functions aren't restarted; the caller is
expected to check that the waited-for condition actually happened, so
returning prematurely isn't considered problematic.
EINTR is one of those "special" errors (like EAGAIN) which don't
actually indicate an error. In the context of select(), a return value of
-1 with errno set to EINTR should normally be handled in the same way as a
return value of zero, i.e. "nothing has happened yet, try again".
While the EINTR case isn't identical to the zero-return case, it's much
closer to it than it is to a genuine error. If it's being treated like
genuine errors (i.e. raising an exception), that's a defect in the Python
bindings. In which case, I'd suggest catching the exception and checking
the error code, e.g.:
def myselect(rlist, wlist, xlist, timeout = None):
try:
return select.select(rlist, wlist, xlist, timeout)
except select.error, e:
if e[0] == errno.EINTR:
return 0
raise
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
connect SIGINT to custom interrupt handler Christoph Scheingraber <chris@spam.org> - 2011-05-15 09:44 +0000
Re: connect SIGINT to custom interrupt handler Christoph Scheingraber <chris@spam.org> - 2011-05-15 14:32 +0000
Re: connect SIGINT to custom interrupt handler Chris Angelico <rosuav@gmail.com> - 2011-05-16 01:30 +1000
Re: connect SIGINT to custom interrupt handler Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-05-15 17:43 +0200
Re: connect SIGINT to custom interrupt handler Christoph Scheingraber <spam@scheingraber.net> - 2011-05-15 17:05 +0000
Re: connect SIGINT to custom interrupt handler Nobody <nobody@nowhere.com> - 2011-05-16 03:28 +0100
Re: connect SIGINT to custom interrupt handler Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-05-20 09:38 +0200
Re: connect SIGINT to custom interrupt handler Nobody <nobody@nowhere.com> - 2011-05-16 03:53 +0100
Re: connect SIGINT to custom interrupt handler Nobody <nobody@nowhere.com> - 2011-05-15 14:08 +0100
csiph-web