Skip to content

Deadlock when mixing event loops and subprocesses #88056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ehrmann mannequin opened this issue Apr 19, 2021 · 3 comments
Closed

Deadlock when mixing event loops and subprocesses #88056

ehrmann mannequin opened this issue Apr 19, 2021 · 3 comments
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes topic-asyncio type-bug An unexpected behavior, bug, or error

Comments

@ehrmann
Copy link
Mannequin

ehrmann mannequin commented Apr 19, 2021

BPO 43890
Nosy @ehrmann
Files
  • subprocess_asyncio_deadlock.py
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2021-04-19.18:36:19.433>
    labels = ['type-bug', '3.8']
    title = 'Deadlock when mixing event loops and subprocesses'
    updated_at = <Date 2021-04-19.18:36:19.433>
    user = 'https://github.com/ehrmann'

    bugs.python.org fields:

    activity = <Date 2021-04-19.18:36:19.433>
    actor = 'thomas'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = []
    creation = <Date 2021-04-19.18:36:19.433>
    creator = 'thomas'
    dependencies = []
    files = ['49967']
    hgrepos = []
    issue_num = 43890
    keywords = []
    message_count = 1.0
    messages = ['391386']
    nosy_count = 1.0
    nosy_names = ['thomas']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue43890'
    versions = ['Python 3.8']

    @ehrmann
    Copy link
    Mannequin Author

    ehrmann mannequin commented Apr 19, 2021

    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.

    @ehrmann ehrmann mannequin added 3.8 (EOL) end of life type-bug An unexpected behavior, bug, or error labels Apr 19, 2021
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @kumaraditya303 kumaraditya303 added 3.11 only security fixes 3.10 only security fixes 3.9 only security fixes and removed 3.8 (EOL) end of life labels Apr 16, 2022
    @kumaraditya303
    Copy link
    Contributor

    kumaraditya303 commented Apr 16, 2022

    Reproduced on 3.11, I think it is because of fork

    @kumaraditya303
    Copy link
    Contributor

    kumaraditya303 commented Apr 16, 2022

    Duplicate of #90368

    So after some investigation, this issue is a duplicate of #90368 and if you remove the print calls it is fixed. Moreover the fix in #30310 fixes this issue so closing as duplicate.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes 3.11 only security fixes topic-asyncio type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants