This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Event loop incorrectly inherited in child processes.
Type: behavior Stage:
Components: asyncio Versions: Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Elvis.Pranskevichus, yselivanov
Priority: normal Keywords:

Created on 2017-07-19 22:49 by Elvis.Pranskevichus, last changed 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
test.py Elvis.Pranskevichus, 2017-07-19 22:49 Example
Messages (1)
msg298693 - (view) Author: Elvis Pranskevichus (Elvis.Pranskevichus) * (Python triager) Date: 2017-07-19 22:49
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 <module>
    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
History
Date User Action Args
2022-04-11 14:58:49adminsetgithub: 75155
2017-07-19 22:49:35Elvis.Pranskevichuscreate