Author njs
Recipients njs, vstinner
Date 2017-04-12.08:54:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1491987273.45.0.570112423464.issue30050@psf.upfronthosting.co.za>
In-reply-to
Content
When a wakeup fd is registered via signal.set_wakeup_fd, then the C level signal handler writes a byte to the wakeup fd on each signal received. If this write fails, then it prints an error message to the console.

Some projects use the wakeup fd as a way to see which signals have occurred (asyncio, curio). Others use it only as a toggle for "a wake up is needed", and transmit the actual data out-of-line (twisted, tornado, trio – I guess it has something to do with the letter "t").

One way that writing to the wakeup fd can fail is if the pipe or socket's buffer is already full, in which case we get EWOULDBLOCK or WSAEWOULDBLOCK. For asyncio/curio, this is a problem: it indicates a lost signal! Printing to the console isn't a great solution, but it's better than letting the error pass silently.

For twisted/tornado/trio, this is a normal and expected thing – the semantics we want are that after a signal is received then the fd will be readable, and if its buffer is full then it's certainly readable! So for them, EWOULDBLOCK/WSAEWOULDBLOCK are *success* conditions. Yet currently, the signal module insists on printing a scary message to the console whenever we succeed in this way.

It would be nice if there were a way to disable this; perhaps something like: signal.set_wakeup_fd(fd, warn_on_full_buffer=False)

This is particularly annoying for trio, because I try to minimize the size of the wakeup fd's send buffer to avoid wasting non-swappable kernel memory on what's essentially an overgrown bool. This ends up meaning that on Linux the buffer is 6 bytes, and on MacOS it's 1 byte. So currently I don't use the wakeup fd on Linux/MacOS, which is *mostly*  OK but it would be better if we could use it. Trio bug with a few more details: https://github.com/python-trio/trio/issues/109
History
Date User Action Args
2017-04-12 08:54:33njssetrecipients: + njs, vstinner
2017-04-12 08:54:33njssetmessageid: <1491987273.45.0.570112423464.issue30050@psf.upfronthosting.co.za>
2017-04-12 08:54:33njslinkissue30050 messages
2017-04-12 08:54:33njscreate