New submission from Nathaniel Smith:

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

----------
messages: 291532
nosy: haypo, njs
priority: normal
severity: normal
status: open
title: Please provide a way to disable the warning printed if the signal 
module's wakeup fd overflows
versions: Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30050>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to