Skip to content

Conversation

smurfix
Copy link

@smurfix smurfix commented Mar 11, 2024

Assigning to a variable is atomic anyway.
The lock is thus superfluous.

Assigning to a variable is atomic anyway.
The lock is thus superfluous.
Copy link
Contributor

@PierreF PierreF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a simple assignment. I'm unsure whether this is safe to remove the lock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants