@@ -249,6 +249,7 @@ def __init__(self, host=None, port=0, unixsocket=None, nathost=None, natport=Non
249
249
self ._pyroInstances = {} # pyro objects for instance_mode=single (singletons, just one per daemon)
250
250
self .streaming_responses = {} # stream_id -> (client, creation_timestamp, linger_timestamp, stream)
251
251
self .housekeeper_lock = threading .Lock ()
252
+ self .create_single_instance_lock = threading .Lock ()
252
253
self .__mustshutdown .clear ()
253
254
self .methodcall_error_handler = _default_methodcall_error_handler
254
255
@@ -574,12 +575,13 @@ def createInstance(clazz, creator):
574
575
instance_mode , instance_creator = clazz ._pyroInstancing
575
576
if instance_mode == "single" :
576
577
# create and use one singleton instance of this class (not a global singleton, just exactly one per daemon)
577
- instance = self ._pyroInstances .get (clazz )
578
- if not instance :
579
- log .debug ("instancemode %s: creating new pyro object for %s" , instance_mode , clazz )
580
- instance = createInstance (clazz , instance_creator )
581
- self ._pyroInstances [clazz ] = instance
582
- return instance
578
+ with self .create_single_instance_lock :
579
+ instance = self ._pyroInstances .get (clazz )
580
+ if not instance :
581
+ log .debug ("instancemode %s: creating new pyro object for %s" , instance_mode , clazz )
582
+ instance = createInstance (clazz , instance_creator )
583
+ self ._pyroInstances [clazz ] = instance
584
+ return instance
583
585
elif instance_mode == "session" :
584
586
# Create and use one instance for this proxy connection
585
587
# the instances are kept on the connection object.
0 commit comments