python-dependency-injector icon indicating copy to clipboard operation
python-dependency-injector copied to clipboard

What is Local context

Open DGDarkKing opened this issue 1 year ago • 1 comments
trafficstars

I tried find examples but attempts were unsuccessful

How I understand: Singleton - One object of all container lifetime ThreadSafeSingleton - Same as Singleton and thread safe

ContextLocalSingleton - What did you mean by Local context ThreadLocalSingleton - Same as ContextLocalSingletonby but thread safe

After practice research - this are look like simple Singleton or ThreadSafeSingleton

I understand a local context as creation singleton object by "with" statement. Found reset_singletons method for container and returns SingletonResetContext is usage in "with" statement. But the method reset all singletons: Singleton, ContextLocalSingleton etc. And singletons reset both in context and in source container. The reset make inside a "with" statement and again after it for every singletons.

DGDarkKing avatar Jul 12 '24 19:07 DGDarkKing