Alan Jenkins <alan.christopher.jenk...@gmail.com> added the comment:

Here's a simple test case that fails on the main branch.

https://github.com/sourcejedi/cpython/commit/50184ea3b354fd775866d036ccee058ec6734927

> the patch assumes that python signal handler will be called *before* reading 
> from self-pipe. 
> Otherwise, a signal callback will be postponed up to next writing to the 
> pipe, which looks like a hidden bug.

I think it will be?  I can imagine it being a concern for future changes 
though.  I thought it could break if anyone takes seriously the comment "XXX 
Signals should be recorded per thread, now we have thread state." :-).

But if we're not confident, surely all we have to do is make sure to call 
_write_to_self() at the end of the python signal handler 
(_UnixSelectorEventLoop._sig_handler()).

It seems a pity not to have example code we can point to, that handles signals 
correctly.  Even if it's too tedious to explain the correct way in the official 
docs.

----------
nosy: +sourcejedi

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

Reply via email to