Skip to content

Commit 39f9be4

Browse files
author
remimd
committed
Revert last 2 commits 🚑️
1 parent 58961ce commit 39f9be4

2 files changed

Lines changed: 23 additions & 8 deletions

File tree

injection/_core/module.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -808,11 +808,8 @@ def change_priority(self, module: Module, priority: Priority | PriorityStr) -> S
808808
return self
809809

810810
def unlock(self) -> Self:
811-
event = UnlockCalled()
812-
813-
with self.dispatch(event, lock_bypass=True):
814-
for broker in self.__brokers:
815-
broker.unlock()
811+
for broker in self.__brokers:
812+
broker.unlock()
816813

817814
return self
818815

@@ -848,9 +845,8 @@ def on_event(self, event: Event, /) -> ContextManager[None]:
848845
return self.dispatch(self_event)
849846

850847
@contextmanager
851-
def dispatch(self, event: Event, *, lock_bypass: bool = False) -> Iterator[None]:
852-
if not lock_bypass:
853-
self.__check_locking()
848+
def dispatch(self, event: Event) -> Iterator[None]:
849+
self.__check_locking()
854850

855851
with self.__channel.dispatch(event):
856852
try:

tests/core/test_module.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,25 @@ class C(A): ...
405405
assert isinstance(b1.a, A)
406406
assert isinstance(b2.a, C)
407407

408+
def test_unlock_with_locked_module_in_use(self, module):
409+
second_module = Module()
410+
module.use(second_module)
411+
412+
@module.singleton
413+
class A: ...
414+
415+
@second_module.singleton
416+
class B: ...
417+
418+
a = module.get_instance(A)
419+
b = module.get_instance(B)
420+
421+
module.unlock()
422+
assert a is not module.get_instance(A)
423+
assert b is not module.get_instance(B)
424+
425+
# TODO: not yet implemented
426+
@pytest.mark.skip
408427
def test_unlock_with_module_in_use_raise_module_lock_error(self, module):
409428
second_module = Module()
410429
module.use(second_module)

0 commit comments

Comments
 (0)