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

gh-92530: Fix an issue that occurred after interrupting threading.Condition.notify #92534

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented May 9, 2022

Fixes #92530.

Copy link
Contributor

@hauntsaninja hauntsaninja left a comment

Removing the deque entirely undoes the optimisation from https://bugs.python.org/issue17385

@serhiy-storchaka
Copy link
Member Author

@serhiy-storchaka serhiy-storchaka commented May 12, 2022

No, self._waiters is still a deque.

@serhiy-storchaka serhiy-storchaka requested a review from pitrou May 12, 2022
@serhiy-storchaka serhiy-storchaka merged commit 70af994 into python:main May 16, 2022
13 checks passed
@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented May 16, 2022

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10, 3.11.
🐍🍒🤖

@serhiy-storchaka serhiy-storchaka deleted the threading-condition-notify-interrupt branch May 16, 2022
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented May 16, 2022

GH-92829 is a backport of this pull request to the 3.11 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 16, 2022
…ng.Condition.notify (pythonGH-92534)

If Condition.notify() was interrupted just after it released the waiter lock,
but before removing it from the queue, the following calls of notify() failed
with RuntimeError: cannot release un-acquired lock.
(cherry picked from commit 70af994)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 16, 2022
…ng.Condition.notify (pythonGH-92534)

If Condition.notify() was interrupted just after it released the waiter lock,
but before removing it from the queue, the following calls of notify() failed
with RuntimeError: cannot release un-acquired lock.
(cherry picked from commit 70af994)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented May 16, 2022

GH-92830 is a backport of this pull request to the 3.10 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 16, 2022
…ng.Condition.notify (pythonGH-92534)

If Condition.notify() was interrupted just after it released the waiter lock,
but before removing it from the queue, the following calls of notify() failed
with RuntimeError: cannot release un-acquired lock.
(cherry picked from commit 70af994)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented May 16, 2022

GH-92831 is a backport of this pull request to the 3.9 branch.

@vstinner
Copy link
Member

@vstinner vstinner commented May 16, 2022

I reviewed your fix twice. Ok, now it makes sense and the comment is enough to explain the fix and the code.

It might be safe to check if the waiter is already released by calling the .locked() method, but I don't think that it's worth it and it might introduce new subtle concurrency issues. In short, the fix is correct :-)

@serhiy-storchaka
Copy link
Member Author

@serhiy-storchaka serhiy-storchaka commented May 16, 2022

EAFP is so superior to LBYL here, that the latter I did not even consider.

ambv pushed a commit that referenced this issue May 16, 2022
…dition.notify (GH-92534) (GH-92831)

If Condition.notify() was interrupted just after it released the waiter lock,
but before removing it from the queue, the following calls of notify() failed
with RuntimeError: cannot release un-acquired lock.
(cherry picked from commit 70af994)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
ambv pushed a commit that referenced this issue May 16, 2022
…dition.notify (GH-92534) (GH-92830)

If Condition.notify() was interrupted just after it released the waiter lock,
but before removing it from the queue, the following calls of notify() failed
with RuntimeError: cannot release un-acquired lock.
(cherry picked from commit 70af994)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
miss-islington added a commit that referenced this issue May 17, 2022
…ing.Condition.notify (GH-92534) (GH-92829)

If Condition.notify() was interrupted just after it released the waiter lock,
but before removing it from the queue, the following calls of notify() failed
with RuntimeError: cannot release un-acquired lock.
(cherry picked from commit 70af994)


Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>

Automerge-Triggered-By: GH:serhiy-storchaka
hello-adam pushed a commit to hello-adam/cpython that referenced this issue Jun 2, 2022
…ng.Condition.notify (pythonGH-92534) (pythonGH-92831)

If Condition.notify() was interrupted just after it released the waiter lock,
but before removing it from the queue, the following calls of notify() failed
with RuntimeError: cannot release un-acquired lock.
(cherry picked from commit 70af994)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants