STINNER Victor added the comment:

I created a new repository just for this issue:
http://hg.python.org/sandbox/issue21645

I added a lot of debug. It looks like a race condition: the SIGCHLD signal is 
handled in a thread B (a C thread, not a Python), whereas the asyncio event 
loop is running in a thread A (the main thread, a Python thread).

Debug of the test which blocks:
---

PIPE: (7, 8)
threads [<_MainThread(MainThread, started 34384933888)>]
[pid 78351] _run_once: thread=34384933888
Execute <Handle Task._step() created at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/tasks.py:74>
[pid 78351] _run_once: thread=34384933888
Execute <Handle StreamReaderProtocol.connection_made(<_UnixReadPipeTransport 
fd=7 polling>) created at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/unix_events.py:287>
Execute <Handle Future._set_result_unless_cancelled(None) created at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/unix_events.py:290>
[pid 78351] _run_once: thread=34384933888
Execute <Handle Task._wakeup(<Future finished result=None>) created at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/futures.py:239>
Read pipe 7 connected: (<_UnixReadPipeTransport fd=7 polling>, 
<asyncio.streams.StreamReaderProtocol object at 0x806e257a8>)
[pid 78351] _run_once: thread=34384933888
Execute <Handle _raise_stop_error(<Task finished 
coro=<BaseEventLoop.connect_read_pipe() done, defined at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/base_events.py:767>
 created at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/base_events.py:258
 result=(<_UnixReadPipeTransport fd=7 polling>, 
<asyncio.streams.StreamReaderProtocol object at 0x806e257a8>)>) at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/base_events.py:95
 created at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/futures.py:239>
Execute <Handle _raise_stop_error(<Task finished 
coro=<BaseEventLoop.connect_read_pipe() done, defined at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/base_events.py:767>
 created at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/base_events.py:258
 result=(<_UnixReadPipeTransport fd=7 polling>, 
<asyncio.streams.StreamReaderProtocol object at 0x806e257a8>)>) at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/base_events.py:95
 created at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/futures.py:239>:
 FAIL! _StopError()
add_signal_handler(Signals.SIGCHLD, <bound method SafeChildWatcher._sig_chld of 
<asyncio.unix_events.SafeChildWatcher object at 0x806e25810>>, ())
PY signal.signal(Signals.SIGCHLD)
[pid 78351] _run_once: thread=34384933888
Execute <Handle Task._step() created at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/tasks.py:74>
execute program '/usr/home/buildbot/buildarea/custom.krah-freebsd/build/python'
process '/usr/home/buildbot/buildarea/custom.krah-freebsd/build/python' 
created: pid 78390
execute program 
'/usr/home/buildbot/buildarea/custom.krah-freebsd/build/python': 
<_UnixSubprocessTransport pid=78390>
[pid 78351] _run_once: thread=34384933888
Execute <Handle 
SubprocessStreamProtocol.connection_made(<_UnixSubprocessTransport pid=78390>) 
created at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/base_subprocess.py:121>
[pid 78351] _run_once: thread=34384933888
Execute <Handle Task._wakeup(<Future finished result=None>) created at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/futures.py:239>
[pid 78351] _run_once: thread=34384933888
Execute <Handle _raise_stop_error(<Task finished coro=<create_subprocess_exec() 
done, defined at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/subprocess.py:208>
 created at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/base_events.py:258
 result=<Process 78390>>) at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/base_events.py:95
 created at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/futures.py:239>
Execute <Handle _raise_stop_error(<Task finished coro=<create_subprocess_exec() 
done, defined at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/subprocess.py:208>
 created at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/base_events.py:258
 result=<Process 78390>>) at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/base_events.py:95
 created at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/futures.py:239>:
 FAIL! _StopError()
[pid 78351] _run_once: thread=34384933888
Execute <Handle Task._step() created at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/tasks.py:74>
[pid 78351] _run_once: thread=34384933888
select(None)
(1) import
(2) dump traceback
select(None) -> [(SelectorKey(fileobj=7, fd=7, events=1, data=(<Handle 
_UnixReadPipeTransport._read_ready() created at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/selector_events.py:183>,
 None)), 1)]
poll took 25.964 ms: [(SelectorKey(fileobj=7, fd=7, events=1, data=(<Handle 
_UnixReadPipeTransport._read_ready() created at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/selector_events.py:183>,
 None)), 1)]
Execute <Handle _UnixReadPipeTransport._read_ready() created at 
/usr/home/buildbot/buildarea/custom.krah-freebsd/build/Lib/asyncio/selector_events.py:183>
[pid 78351] _run_once: thread=34384933888
select(None)
(3) write into 8
(4) close 8
(5) exit
[pid=78351] main_thread=34384933888
[78351] C signal.signal(20)
[78351] C signal_handler: sig_num=20, thread=34468857856
C signal_handler: trip signal (tripped=0)
[78351] trip_signal(20)
trip_signal(20); write()
select(None) -> [(SelectorKey(fileobj=5, fd=5, events=1, data=(<Handle 
BaseSelectorEventLoop._read_from_self()>, None)), 1)]
poll took 4.902 ms: [(SelectorKey(fileobj=5, fd=5, events=1, data=(<Handle 
BaseSelectorEventLoop._read_from_self()>, None)), 1)]
Execute <Handle BaseSelectorEventLoop._read_from_self()>
[thread=34384933888] _read_from_self
_read_from_self -> b'\x14'
[thread=34384933888] _read_from_self
_read_from_self -> blocking, stop
[pid 78351] _run_once: thread=34384933888
select(None)
trip_signal(20); write() -> 1
[78351] Py_AddPendingCall(checksignals_witharg), thread=34468857856
---

----------

_______________________________________
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