python-injection 0.18.4__py3-none-any.whl → 0.18.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- injection/_core/module.py +19 -8
- {python_injection-0.18.4.dist-info → python_injection-0.18.5.dist-info}/METADATA +1 -1
- {python_injection-0.18.4.dist-info → python_injection-0.18.5.dist-info}/RECORD +5 -5
- {python_injection-0.18.4.dist-info → python_injection-0.18.5.dist-info}/WHEEL +0 -0
- {python_injection-0.18.4.dist-info → python_injection-0.18.5.dist-info}/licenses/LICENSE +0 -0
injection/_core/module.py
CHANGED
@@ -156,6 +156,12 @@ class ModulePriorityUpdated(ModuleEvent):
|
|
156
156
|
)
|
157
157
|
|
158
158
|
|
159
|
+
@dataclass(frozen=True, slots=True)
|
160
|
+
class UnlockCalled(Event):
|
161
|
+
def __str__(self) -> str:
|
162
|
+
return "An `unlock` method has been called."
|
163
|
+
|
164
|
+
|
159
165
|
"""
|
160
166
|
Broker
|
161
167
|
"""
|
@@ -179,7 +185,7 @@ class Broker(Protocol):
|
|
179
185
|
raise NotImplementedError
|
180
186
|
|
181
187
|
@abstractmethod
|
182
|
-
def
|
188
|
+
def unsafe_unlocking(self) -> None:
|
183
189
|
raise NotImplementedError
|
184
190
|
|
185
191
|
@abstractmethod
|
@@ -289,12 +295,10 @@ class Locator(Broker):
|
|
289
295
|
|
290
296
|
return self
|
291
297
|
|
292
|
-
def
|
298
|
+
def unsafe_unlocking(self) -> None:
|
293
299
|
for injectable in self.__injectables:
|
294
300
|
injectable.unlock()
|
295
301
|
|
296
|
-
return self
|
297
|
-
|
298
302
|
async def all_ready(self) -> None:
|
299
303
|
for injectable in self.__injectables:
|
300
304
|
if injectable.is_locked:
|
@@ -802,11 +806,17 @@ class Module(Broker, EventListener):
|
|
802
806
|
return self
|
803
807
|
|
804
808
|
def unlock(self) -> Self:
|
805
|
-
|
806
|
-
|
809
|
+
event = UnlockCalled()
|
810
|
+
|
811
|
+
with self.dispatch(event, lock_bypass=True):
|
812
|
+
self.unsafe_unlocking()
|
807
813
|
|
808
814
|
return self
|
809
815
|
|
816
|
+
def unsafe_unlocking(self) -> None:
|
817
|
+
for broker in self.__brokers:
|
818
|
+
broker.unsafe_unlocking()
|
819
|
+
|
810
820
|
def load_profile(self, *names: str) -> ContextManager[Self]:
|
811
821
|
modules = (self.from_name(name) for name in names)
|
812
822
|
self.unlock().init_modules(*modules)
|
@@ -839,8 +849,9 @@ class Module(Broker, EventListener):
|
|
839
849
|
return self.dispatch(self_event)
|
840
850
|
|
841
851
|
@contextmanager
|
842
|
-
def dispatch(self, event: Event) -> Iterator[None]:
|
843
|
-
|
852
|
+
def dispatch(self, event: Event, *, lock_bypass: bool = False) -> Iterator[None]:
|
853
|
+
if not lock_bypass:
|
854
|
+
self.__check_locking()
|
844
855
|
|
845
856
|
with self.__channel.dispatch(event):
|
846
857
|
try:
|
@@ -7,7 +7,7 @@ injection/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
7
|
injection/_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
8
|
injection/_core/descriptors.py,sha256=jH0pyIlPurMmU4yXr-HKS_7BJ-9d0XUvEx4pQre3QeI,704
|
9
9
|
injection/_core/injectables.py,sha256=Rg1nxDkbcpeX4ELohrNVMguPhN36SNQuD0JKfyfL6bI,6192
|
10
|
-
injection/_core/module.py,sha256=
|
10
|
+
injection/_core/module.py,sha256=uCUohfXA1sFA0WSHLC-ROqKP7QqZPTu5kJ3M26fqsPU,32255
|
11
11
|
injection/_core/scope.py,sha256=OBzVY1mUApryqIZKQtwHz7wiuY13MfouyaHp50DpWeQ,8300
|
12
12
|
injection/_core/slots.py,sha256=g9TG6CbqRzCsjg01iPyfRtTTUCJnnJOwcj9mJabH0dc,37
|
13
13
|
injection/_core/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -22,7 +22,7 @@ injection/ext/fastapi.py,sha256=layUUer5IWiZX6Mmx1_RCYDLNCtEHtpya5ZL6TTBOkY,968
|
|
22
22
|
injection/ext/fastapi.pyi,sha256=8OZEUjHFB9n7QXv_dtXdDuXW-r2huQEFsJ03gJOOvwQ,125
|
23
23
|
injection/testing/__init__.py,sha256=PsrvNxYvn11if8CJpEYxcTxniqMt2w_7fBaDkY9RA5o,898
|
24
24
|
injection/testing/__init__.pyi,sha256=iOii0i9F5n7znltGeGQYI2KXC_if9SAogLh1h03yx-0,540
|
25
|
-
python_injection-0.18.
|
26
|
-
python_injection-0.18.
|
27
|
-
python_injection-0.18.
|
28
|
-
python_injection-0.18.
|
25
|
+
python_injection-0.18.5.dist-info/METADATA,sha256=HoWHgEdcmYMVXANEXTFUSIqffaZ8YqU_75rcvf9wckQ,3397
|
26
|
+
python_injection-0.18.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
27
|
+
python_injection-0.18.5.dist-info/licenses/LICENSE,sha256=oC77BOa9kaaQni5rW-Z-ytz3E5h4EVg248BHg9UFgyg,1063
|
28
|
+
python_injection-0.18.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|