This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author neologix
Recipients alanwilter, georg.brandl, neologix, pitrou
Date 2011-01-09.18:36:40
SpamBayes Score 2.0073027e-10
Marked as misclassified No
Message-id <AANLkTikt6Dc9xw4HVWYE4ew7jSivJUMoUc14uVgroBvW@mail.gmail.com>
In-reply-to <1294586041.23.0.803705323781.issue9504@psf.upfronthosting.co.za>
Content
> Antoine Pitrou <pitrou@free.fr> added the comment:
>
> Charles-François' analysis seems to be right. Note that the actual issue here is that read() always succeeds, returning a partial result (because you're executing a command, 'find /', which outputs a lot of data). If read() were interrupted before anything could be read, it would return EINTR and the handler would get executed immediately.
>
> Anyone wants to propose a patch + tests?
>

Attached is a tentative patch: it checks for pending signals inside
_bufferedreader_read_generic, fileio_readall, and rawiobase_readall.
I tested quickly on regular files and on pipes, and handlers are now
called on time. As a an obvious bonus, it's also easier to interrupt a
script doing I/O with a KeyboardInterrupt (SIGINT).
If nothing seems blatantly wrong about this patch, I will go ahead and
try to write some tests for this.

Charles

> ----------
> versions: +Python 3.2
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue9504>
> _______________________________________
>
Files
File name Uploaded
io_signal.diff neologix, 2011-01-09.18:36:40
History
Date User Action Args
2011-01-09 18:36:42neologixsetrecipients: + neologix, georg.brandl, pitrou, alanwilter
2011-01-09 18:36:40neologixlinkissue9504 messages
2011-01-09 18:36:40neologixcreate