Documentation: "Using Scopes to manage Resources"#252
Documentation: "Using Scopes to manage Resources"#252bschnitz wants to merge 1 commit intopython-injector:masterfrom
Conversation
docs/scopes.rst
Outdated
| connections. If those resources are shared between multiple classes and should | ||
| not be freed and reallocated in between, then using the :class:`SingletonScope` seems | ||
| to be the right choice. However resources are not freed automatically afterwards | ||
| and bookkeeping must be done manually. However to with some small additions to |
|
Thank you very much for the contribution @bschnitz, it's always nice to see a documentation patch. May I ask about the exact use case you're addressing here? Is it primarly/only about being able to do this? If yes, then it seems to me it's enough for Then |
|
Hi @jstasiak , thank You for having a look! Actually, thats not the whole idea and I have to admit, that the example is too short to grasp it correctly. The idea is, that all objects in CleanupScope are handled, not just the one we directly get in this example. So it's really the context of the Scope and not the one of the object, although it looks a bit misleading here. The usage of I will extend the example a bit, then You may have a look again. Oh, this person named Edit: I extended the motivation a bit. It still feels clumsy, but I hope the idea is clearer now. If You have ideas on improving my horrible writing, feel free to tell ;). |
09274c9 to
40533ba
Compare
I tried to make a minimal example on how to automatically free resources with a custom
Scope. Since I'm still learning how to use the python-injector, there may be many misconceptions, so please have a firm look.