Skip to content

Commit 240c8ab

Browse files
authored
refactoring: 🧵 Add lock in from_name method
1 parent d257312 commit 240c8ab

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

‎injection/core/module.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,10 @@ def from_name(cls, name: str) -> Self:
624624
with suppress(KeyError):
625625
return cls.__instances[name]
626626

627-
instance = cls(name)
628-
cls.__instances[name] = instance
627+
with synchronized():
628+
instance = cls(name)
629+
cls.__instances[name] = instance
630+
629631
return instance
630632

631633
@classmethod

0 commit comments

Comments
 (0)