Merge branch 'release/4.3.7' into master

This commit is contained in:
Roman Mogylatov 2020-11-10 17:02:56 -05:00
commit 26a89d664b
5 changed files with 1925 additions and 1787 deletions

View File

@ -13,3 +13,4 @@ Dependency Injector Contributors
+ Bruno P. Kinoshita (kinow)
+ RobinsonMa (RobinsonMa)
+ Rüdiger Busche (JarnoRFB)
+ Dmitry Rassoshenko (rda-dev)

View File

@ -7,6 +7,12 @@ that were made in every particular version.
From version 0.7.6 *Dependency Injector* framework strictly
follows `Semantic versioning`_
4.3.7
-----
- Fix race in ``ThreadSafeSingleton``. Many thanks to
`Dmitry Rassoshenko aka rda-dev <https://github.com/rda-dev>`_ for the pull request
(See PR `#322 <https://github.com/ets-labs/python-dependency-injector/pull/322>`_).
4.3.6
-----
- Fix changelog typo.

View File

@ -1,6 +1,6 @@
"""Top-level package."""
__version__ = '4.3.6'
__version__ = '4.3.7'
"""Version number.
:type: str

File diff suppressed because it is too large Load Diff

View File

@ -2178,15 +2178,19 @@ cdef class ThreadSafeSingleton(BaseSingleton):
:rtype: None
"""
self.__storage = None
with self.__storage_lock:
self.__storage = None
cpdef object _provide(self, tuple args, dict kwargs):
"""Return single instance."""
with self.__storage_lock:
if self.__storage is None:
self.__storage = __factory_call(self.__instantiator,
args, kwargs)
return self.__storage
storage = self.__storage
if storage is None:
with self.__storage_lock:
if self.__storage is None:
self.__storage = __factory_call(self.__instantiator,
args, kwargs)
storage = self.__storage
return storage
cdef class DelegatedThreadSafeSingleton(ThreadSafeSingleton):