STINNER Victor added the comment:

(1) the thread B gets the SIGCHLD signal: it writes a byte into the "self" pipe 
of the event loop

   C signal_handler: sig_num=20, thread=34468857856
   trip_signal(20): write()

(2) in the main thread, the event loop is awaken by the write in the pipe... 
but there is nothing to do

   _read_from_self -> b'\x14', thread=34384933888

(3) the thread B schedules the callback

   Py_AddPendingCall(checksignals_witharg), thread=34468857856

(I modified the output a little bit for readability.)

IMO the problem is that asyncio relies on two events:

* signal number written in the "self" pipe of the event loop
* callback scheduled by the C handler

A solution would be to schedule the callback in the event loop. Since Python 
3.3, the C signal handler writes the signal number, which should be enough to 
find and schedule the Python callback.

----------

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

Reply via email to