39
39
from injection .common .event import Event , EventChannel , EventListener
40
40
from injection .common .lazy import Lazy , LazyMapping
41
41
from injection .common .queue import LimitedQueue
42
- from injection .common .tools .threading import (
43
- frozen_collection ,
44
- synchronized ,
45
- thread_lock ,
46
- )
42
+ from injection .common .tools .threading import synchronized
47
43
from injection .common .tools .type import find_types , format_type , get_origins
48
44
from injection .exceptions import (
49
45
InjectionError ,
@@ -193,7 +189,7 @@ def get_instance(self) -> _T:
193
189
with suppress (KeyError ):
194
190
return self .cache [self .__INSTANCE_KEY ]
195
191
196
- with thread_lock :
192
+ with synchronized () :
197
193
instance = self .factory ()
198
194
self .cache [self .__INSTANCE_KEY ] = instance
199
195
@@ -273,7 +269,7 @@ def __injectables(self) -> frozenset[Injectable]:
273
269
def update (self , classes : Iterable [type ], injectable : Injectable , override : bool ):
274
270
classes = frozenset (get_origins (* classes ))
275
271
276
- with thread_lock :
272
+ with synchronized () :
277
273
if not injectable :
278
274
classes -= self .__classes
279
275
override = True
@@ -289,7 +285,7 @@ def update(self, classes: Iterable[type], injectable: Injectable, override: bool
289
285
290
286
return self
291
287
292
- @synchronized
288
+ @synchronized ()
293
289
def unlock (self ):
294
290
for injectable in self .__injectables :
295
291
injectable .unlock ()
@@ -360,7 +356,7 @@ def is_locked(self) -> bool:
360
356
361
357
@property
362
358
def __brokers (self ) -> Iterator [Broker ]:
363
- yield from frozen_collection (self .__modules )
359
+ yield from tuple (self .__modules )
364
360
yield self .__container
365
361
366
362
def injectable (
@@ -502,7 +498,7 @@ def change_priority(self, module: Module, priority: ModulePriority):
502
498
503
499
return self
504
500
505
- @synchronized
501
+ @synchronized ()
506
502
def unlock (self ):
507
503
for broker in self .__brokers :
508
504
broker .unlock ()
@@ -697,7 +693,7 @@ def bind(
697
693
return Arguments (bound .args , bound .kwargs )
698
694
699
695
def update (self , module : Module ):
700
- with thread_lock :
696
+ with synchronized () :
701
697
self .__dependencies = Dependencies .resolve (
702
698
self .signature ,
703
699
module ,
@@ -730,7 +726,5 @@ def __consume_setup_queue(self):
730
726
return self
731
727
732
728
def __set_signature (self , signature : Signature ):
733
- with thread_lock :
734
- self .__signature__ = signature
735
-
729
+ self .__signature__ = signature
736
730
return self
0 commit comments