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: Deadlock when mixing event loops and subprocesses
Type: behavior Stage:
Components: Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: thomas
Priority: normal Keywords:

Created on 2021-04-19 18:36 by thomas, last changed 2022-04-11 14:59 by admin.

Files
File name Uploaded Description Edit
subprocess_asyncio_deadlock.py thomas, 2021-04-19 18:36
Messages (1)
msg391386 - (view) Author: Thomas Buhrmann (thomas) Date: 2021-04-19 18:36
When mixing code that spawns subprocesses with code that creates event loops, Python appears to deadlock.

In the attached example, when WORKERS = 16 and ASYNC_WORKERS = 8, Python will sometimes (50% of the time?) deadlock, never exiting, with no exceptions raised. Oddly, if ASYNC_WORKERS is set to 0 or 16 (i.e., only subprocesses or only event loops), it runs reliably.

I tested this in an x86_64 Ubuntu 20.04.2 VM with Python 3.8.6. I was only able to reproduce it when the VM had more than one CPU, and I was unable to reproduce it on x86_64 MacOS.
History
Date User Action Args
2022-04-11 14:59:44adminsetgithub: 88056
2021-04-19 18:36:19thomascreate