mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 17:47:02 +03:00
Fix ThreadSafeSingleton synchronization issue (#434)
* Fix ThreadSafeSingleton synchronization issue * Update changelog
This commit is contained in:
parent
fca9fd498c
commit
1aef599606
|
@ -7,6 +7,12 @@ that were made in every particular version.
|
||||||
From version 0.7.6 *Dependency Injector* framework strictly
|
From version 0.7.6 *Dependency Injector* framework strictly
|
||||||
follows `Semantic versioning`_
|
follows `Semantic versioning`_
|
||||||
|
|
||||||
|
Development version
|
||||||
|
-------------------
|
||||||
|
- Fix ``ThreadSafeSingleton`` synchronization issue.
|
||||||
|
See issue: `#433 <https://github.com/ets-labs/python-dependency-injector/issues/433>`_.
|
||||||
|
Thanks to `@garlandhu <https://github.com/garlandhu>`_ for reporting the issue.
|
||||||
|
|
||||||
4.31.0
|
4.31.0
|
||||||
------
|
------
|
||||||
- Implement providers' lazy initialization.
|
- Implement providers' lazy initialization.
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2819,17 +2819,14 @@ cdef class ThreadSafeSingleton(BaseSingleton):
|
||||||
if instance is None:
|
if instance is None:
|
||||||
with self.__storage_lock:
|
with self.__storage_lock:
|
||||||
if self.__storage is None:
|
if self.__storage is None:
|
||||||
instance = __factory_call(self.__instantiator, args, kwargs)
|
result = __factory_call(self.__instantiator, args, kwargs)
|
||||||
|
if __is_future_or_coroutine(result):
|
||||||
if __is_future_or_coroutine(instance):
|
|
||||||
future_result = asyncio.Future()
|
future_result = asyncio.Future()
|
||||||
instance = asyncio.ensure_future(instance)
|
result = asyncio.ensure_future(result)
|
||||||
instance.add_done_callback(functools.partial(self._async_init_instance, future_result))
|
result.add_done_callback(functools.partial(self._async_init_instance, future_result))
|
||||||
self.__storage = future_result
|
result = future_result
|
||||||
return future_result
|
self.__storage = result
|
||||||
|
instance = self.__storage
|
||||||
self.__storage = instance
|
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user