Skip to content

fix: deadlock in Measurements.close()#246

Open
manaspros wants to merge 1 commit intogoogle-deepmind:mainfrom
manaspros:fix/measurements-close-deadlock
Open

fix: deadlock in Measurements.close()#246
manaspros wants to merge 1 commit intogoogle-deepmind:mainfrom
manaspros:fix/measurements-close-deadlock

Conversation

@manaspros
Copy link
Contributor

close() holds _channels_lock and then calls close_channel(), which tries to acquire the same lock again. Since threading.Lock is not reentrant this deadlocks immediately.

Also, iterating self._channels while close_channel deletes from it raises RuntimeError: dictionary changed size during iteration.

Fix: replace the loop with a direct self._channels.clear() inside the existing lock, which is both correct and simpler. Added tests including a regression for the deadlock.

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.

1 participant