Issue 30972: Event loop incorrectly inherited in child processes. (original) (raw)
The attached example shows that asyncio.get_event_loop
still returns parent process' event loop in some cases. It appears that the fix in issue #29703 was incomplete:
PARENT PID: 21947, LOOP: <_UnixSelectorEventLoop running=True closed=False debug=False> at 0x7f0fbe7cfd68 WORKER PID: 21948, LOOP: <_UnixSelectorEventLoop running=True closed=False debug=False> at 0x7f0fbe7cfd68 concurrent.futures.process._RemoteTraceback: """ Traceback (most recent call last): File "/usr/lib64/python3.6/concurrent/futures/process.py", line 175, in _process_worker r = call_item.fn(*call_item.args, **call_item.kwargs) File "test.py", line 13, in worker return loop.run_until_complete(worker_coro()) File "/usr/lib64/python3.6/asyncio/base_events.py", line 454, in run_until_complete self.run_forever() File "/usr/lib64/python3.6/asyncio/base_events.py", line 408, in run_forever raise RuntimeError('This event loop is already running') RuntimeError: This event loop is already running """
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "test.py", line 25, in loop.run_until_complete(main()) File "/usr/lib64/python3.6/asyncio/base_events.py", line 466, in run_until_complete return future.result() File "test.py", line 21, in main return await loop.run_in_executor(executor, worker) RuntimeError: This event loop is already running