File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ class SomeDataClass:
8383
8484### Threadsafe injection
8585
86- With ` threadsafe=True ` , the injection logic is wrapped in a ` threading.Lock ` .
86+ With ` threadsafe=True ` , the injection logic is wrapped in a ` threading.RLock ` .
8787
8888``` python
8989@inject (threadsafe = True )
Original file line number Diff line number Diff line change @@ -78,7 +78,9 @@ class LazyInstance[T]:
7878 cls : _InputType [T ],
7979 / ,
8080 default : T = ...,
81+ * ,
8182 module : Module = ...,
83+ threadsafe : bool = ...,
8284 ) -> None : ...
8385 @overload
8486 def __get__ (self , instance : object , owner : type | None = ...) -> T : ...
@@ -292,8 +294,8 @@ class Module:
292294 ) -> _Invertible [T | Default ]:
293295 """
294296 Function used to retrieve an instance associated with the type passed in
295- parameter or `NotImplemented`. Return a `Invertible` object. To access the instance
296- contained in an invertible object, simply use a wavy line (~).
297+ parameter or `NotImplemented`. Return an `Invertible` object. To access the
298+ instance contained in an invertible object, simply use a wavy line (~).
297299
298300 Example: instance = ~lazy_instance
299301 """
Original file line number Diff line number Diff line change @@ -15,9 +15,12 @@ def __init__(
1515 cls : InputType [T ],
1616 / ,
1717 default : T = NotImplemented ,
18+ * ,
1819 module : Module | None = None ,
20+ threadsafe : bool = False ,
1921 ) -> None :
20- self .__value = (module or mod ()).get_lazy_instance (cls , default )
22+ module = module or mod ()
23+ self .__value = module .get_lazy_instance (cls , default , threadsafe = threadsafe )
2124
2225 def __get__ (
2326 self ,
You can’t perform that action at this time.
0 commit comments