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 vstinner
Recipients Sebastian.Kreft.Deezer, giampaolo.rodola, gvanrossum, pitrou, vstinner, yselivanov
Date 2014-05-28.21:13:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1401311615.11.0.492863693343.issue21595@psf.upfronthosting.co.za>
In-reply-to
Content
"Exception ignored when trying to write to the signal wakeup fd" message comes from the signal handler in Modules/signalmodule.c. The problem is that Python gets a lot of SIGCHLD signals (the test scripts creates +300 processes per second on my computer). The producer (signal handler writing the signal number into the "self" pipe) is faster than the consumer (BaseSelectorEventLoop._read_from_self callback).

Attached patch should reduce the risk of seeing the message "Exception ignored when trying to write to the signal wakeup fd". The patch reads all pending of the self pipe, instead of just trying to read a signal byte.

The test script doesn't write the error message anymore when the patch is applied (the script creates more than 300 processes per second).

The patch doesn't solve completly the issue. Other possible enhancements:

* Add a flag in the signal handler to notify that a signal was received, and write a single byte until the flag is reset to False. It would avoid to fill the pipe. It requires to implement a custom signal handler implemented in C, different from signal handlers of the Python module.

* Add an higher priority to callbacks of signal handlers. Asyncio doesn't support priority on callbacks right now.

* Increaze the size of the pipe. On Linux, it looks like "fcntl(fd, F_SETPIPE_SZ, size);" can be used. The maximum size is /proc/sys/fs/pipe-max-size (ex: 1 MB of my Fedora 20).
History
Date User Action Args
2014-05-28 21:13:35vstinnersetrecipients: + vstinner, gvanrossum, pitrou, giampaolo.rodola, yselivanov, Sebastian.Kreft.Deezer
2014-05-28 21:13:35vstinnersetmessageid: <1401311615.11.0.492863693343.issue21595@psf.upfronthosting.co.za>
2014-05-28 21:13:34vstinnerlinkissue21595 messages
2014-05-28 21:13:32vstinnercreate