@@ -95,7 +95,8 @@ def register_proxy(self, proxy: IProxy):
9595 :return: None
9696 """
9797 proxy .initialize_notifier (self .multitonKey )
98- self .proxyMap [proxy .proxy_name ] = proxy
98+ with self .proxyMapLock :
99+ self .proxyMap [proxy .proxy_name ] = proxy
99100 proxy .on_register ()
100101
101102 def retrieve_proxy (self , proxy_name : str ) -> IProxy :
@@ -107,7 +108,8 @@ def retrieve_proxy(self, proxy_name: str) -> IProxy:
107108 :return: the `IProxy` instance previously registered with the given `proxyName`.
108109 :rtype: IProxy
109110 """
110- return self .proxyMap .get (proxy_name )
111+ with self .proxyMapLock :
112+ return self .proxyMap .get (proxy_name )
111113
112114 def has_proxy (self , proxy_name : str ) -> bool :
113115 """
@@ -118,7 +120,8 @@ def has_proxy(self, proxy_name: str) -> bool:
118120 :return: Returns True if the proxy exists in the proxy map, False otherwise.
119121 :rtype: bool
120122 """
121- return self .proxyMap .get (proxy_name ) is not None
123+ with self .proxyMapLock :
124+ return self .proxyMap .get (proxy_name ) is not None
122125
123126 def remove_proxy (self , proxy_name : str ) -> IProxy :
124127 """
@@ -129,9 +132,11 @@ def remove_proxy(self, proxy_name: str) -> IProxy:
129132 :return: the `IProxy` that was removed from the `Model`
130133 :rtype: IProxy
131134 """
132- proxy = self .proxyMap .get (proxy_name )
135+ with self .proxyMapLock :
136+ proxy = self .proxyMap .get (proxy_name )
137+ if proxy :
138+ del self .proxyMap [proxy_name ]
133139 if proxy :
134- del self .proxyMap [proxy_name ]
135140 proxy .on_remove ()
136141 return proxy
137142
0 commit comments