remove superfluous lock#825
Open
smurfix wants to merge 1 commit into
Open
Conversation
Assigning to a variable is atomic anyway. The lock is thus superfluous.
PierreF
reviewed
Mar 24, 2024
Contributor
PierreF
left a comment
There was a problem hiding this comment.
What's the issue we try to solve by removing the locks ?
To my knowledge, this is safe to remove on CPython due to GIL and that Python bytecode are atomic. I don't known if this fact is documented by Python / CPython. I'm not sure this hold for other Python implementation (PyPy, Jython...) and I'm also unsure Python recommend relying on bytecode being atomic.
|
|
||
| with self._callback_mutex: | ||
| self._on_message_filtered[sub] = callback | ||
| self._on_message_filtered[sub] = callback |
Contributor
There was a problem hiding this comment.
This isn't a simple assignment. I'm unsure whether this is safe to remove the lock.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Assigning to a variable is atomic anyway.
The lock is thus superfluous.