Skip to content
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

Race between asyncio Condition.notify() and Task.cancel() may result in lost wakeups. #112202

Closed
kristjanvalur opened this issue Nov 17, 2023 · 1 comment
Labels
topic-asyncio type-bug An unexpected behavior, bug, or error

Comments

@kristjanvalur
Copy link
Contributor

kristjanvalur commented Nov 17, 2023

Bug report

Bug description:

A Task which issues a condition.notify(1) to wake up a Task from a set of waiting tasks to perform some task, e.g. consume a piece of data, may hit a race condition with a simultaneous cancel() of a task among the waiting tasks, resulting in none of the tasks
successfully returning from cond.wait(). This is problematic because because the notify() is essentially lost, and starvation/deadlocks may occur.

PR #112201 contains a fix, as well as documentation updates

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows

Linked PRs

@kristjanvalur kristjanvalur added the type-bug An unexpected behavior, bug, or error label Nov 17, 2023
gvanrossum pushed a commit that referenced this issue Feb 3, 2024
…ith Task.cancel() (#112201)

Also did a general cleanup of asyncio locks.py comments and docstrings.
@gvanrossum
Copy link
Member

@kristjanvalur Thanks for your work on this!

aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
…cing with Task.cancel() (python#112201)

Also did a general cleanup of asyncio locks.py comments and docstrings.
fsc-eriker pushed a commit to fsc-eriker/cpython that referenced this issue Feb 14, 2024
…cing with Task.cancel() (python#112201)

Also did a general cleanup of asyncio locks.py comments and docstrings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-asyncio type-bug An unexpected behavior, bug, or error
Projects
Status: Done
Development

No branches or pull requests

3 participants