Skip to content

Conversation

ameyer-rigetti
Copy link
Contributor

Multiple threads can sometimes collide when building Message._types. This addresses that by ensuring the dictionary is never reset as a whole.

@ameyer-rigetti ameyer-rigetti requested a review from notmgsk April 16, 2021 16:20
@ameyer-rigetti ameyer-rigetti self-assigned this Apr 16, 2021
@ameyer-rigetti ameyer-rigetti requested a review from a team as a code owner April 16, 2021 16:20
@@ -120,13 +120,12 @@ def types():
:return: A dictionary of ``Message`` types.
:rtype: Dict[str,type]
"""
if Message._types is None:
Message._types = {}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

One thread might execute this while another thread is in the middle of building the dictionary. The dictionary is a class member and eventually contains a union of all message types encountered, so this fix should cause no backwards incompatibilities.

Copy link
Contributor

@notmgsk notmgsk left a comment

Choose a reason for hiding this comment

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

Bump the version in VERSION.txt and then it's good to go.

@ameyer-rigetti ameyer-rigetti force-pushed the fix-missing-message-types branch from 0ac037f to 0bdb8da Compare April 19, 2021 16:12
@ameyer-rigetti ameyer-rigetti merged commit 3a73471 into master Apr 19, 2021
@ameyer-rigetti ameyer-rigetti deleted the fix-missing-message-types branch April 19, 2021 17:39
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