Skip to content

Commit

Permalink
Fixes thread-safety issue in Message.types() (#151)
Browse files Browse the repository at this point in the history
* Fixes thread-safety issue in Message.types()

* Bump version to 3.9.1
  • Loading branch information
ameyer-rigetti authored Apr 19, 2021
1 parent f5faec9 commit 3a73471
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.9.0
3.9.1
15 changes: 7 additions & 8 deletions rpcq/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def __eq__(self, other):
def __hash__(self):
return hash((self.__class__, astuple(self)))

_types = None
_types = {}

@staticmethod
def types():
Expand All @@ -120,13 +120,12 @@ def types():
:return: A dictionary of ``Message`` types.
:rtype: Dict[str,type]
"""
if Message._types is None:
Message._types = {}
classes_to_process = [Message]
while classes_to_process:
atom = classes_to_process.pop()
classes_to_process += atom.__subclasses__()
Message._types[atom.__name__] = (atom, inspect.getfullargspec(atom.__init__).args)
classes_to_process = [Message]
while classes_to_process:
atom = classes_to_process.pop()
classes_to_process += atom.__subclasses__()
Message._types[atom.__name__] = (atom, inspect.getfullargspec(atom.__init__).args)

return Message._types


Expand Down

0 comments on commit 3a73471

Please sign in to comment.