python-dependency-injector/examples/providers/singleton_resetting.py
Roman Mogylatov 0bb30f91ef
Singleton docs update (#288)
* Update docblocks of factory provider examples

* Edit singleton docs
2020-09-01 16:04:48 -04:00

20 lines
378 B
Python

"""`Singleton` provider resetting example."""
from dependency_injector import providers
class UserService:
...
user_service_provider = providers.Singleton(UserService)
if __name__ == '__main__':
user_service1 = user_service_provider()
user_service_provider.reset()
users_service2 = user_service_provider()
assert users_service2 is not user_service1