Skip to content

Commit 3a73471

Browse files
Fixes thread-safety issue in Message.types() (#151)
* Fixes thread-safety issue in Message.types() * Bump version to 3.9.1
1 parent f5faec9 commit 3a73471

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

VERSION.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.9.0
1+
3.9.1

rpcq/_base.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def __eq__(self, other):
109109
def __hash__(self):
110110
return hash((self.__class__, astuple(self)))
111111

112-
_types = None
112+
_types = {}
113113

114114
@staticmethod
115115
def types():
@@ -120,13 +120,12 @@ def types():
120120
:return: A dictionary of ``Message`` types.
121121
:rtype: Dict[str,type]
122122
"""
123-
if Message._types is None:
124-
Message._types = {}
125-
classes_to_process = [Message]
126-
while classes_to_process:
127-
atom = classes_to_process.pop()
128-
classes_to_process += atom.__subclasses__()
129-
Message._types[atom.__name__] = (atom, inspect.getfullargspec(atom.__init__).args)
123+
classes_to_process = [Message]
124+
while classes_to_process:
125+
atom = classes_to_process.pop()
126+
classes_to_process += atom.__subclasses__()
127+
Message._types[atom.__name__] = (atom, inspect.getfullargspec(atom.__init__).args)
128+
130129
return Message._types
131130

132131

0 commit comments

Comments
 (0)