STINNER Victor added the comment:

> 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.

Is it a theorical question or did you notice the error in the wild? I mean: 
without sending a signal in a loop.

Right now, we write the signal number into the pipe each time a signal is 
received. Do you need to get N bytes if the signal is received N times? Maybe 
we can use a flag and only write the byte once by signal number?


> Printing to the console isn't a great solution, but it's better than letting 
> the error pass silently.

If the pipe becomes full, you loose signals: it's an hard error. I decided to 
log an error into fd 2 because in a signal handler, the number of allowed 
functions is very limited.

I suggest to have a flag to remind if the pipe overflowed, and in that case: 
schedule a Python callback. The callback can be a new parameter to 
set_wakeup_fd()?

A pipe seems limited to 64 KB, limit hardcoded in Linux kernel code. Is it the 
case if we use a socket pair, as we already do on Windows? Or is it possible to 
increase the socket buffer size?


> 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.

asyncio uses wakeup fd to get signal numbers: it's not only a bool. See the 
issue #21645 for the rationale of using the FD to get signal numbers in asyncio.

It was a bool on Python 2 which only writes NUL bytes into the FD.


Related question: does asyncio support signals on Windows? I added support for 
set_wakeup_fd() to Windows for asyncio, but then I forgot this TODO item :-)

----------

_______________________________________
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