You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/scopes.rst
+102Lines changed: 102 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -62,3 +62,105 @@ Scopes can be retrieved from the injector, as with any other instance. They are
62
62
True
63
63
64
64
For scopes with a transient lifetime, such as those tied to HTTP requests, the usual solution is to use a thread or greenlet-local cache inside the scope. The scope is "entered" in some low-level code by calling a method on the scope instance that creates this cache. Once the request is complete, the scope is "left" and the cache cleared.
65
+
66
+
Using Scopes to manage Resources
67
+
````````````````````````````````
68
+
69
+
Sometimes You need to inject classes, which manage resources, like database
70
+
connections. Imagine You have an :class:`App`, which depends on multiple other
71
+
services and some of these services need to access the Database. The naive
72
+
approach would be to open and close the connection everytime it is needed::
0 commit comments