# Managed spell injection and request scopes **🟡 Intermediate · Lesson 47** Borrow a pooled object per request, give it back when the request ends. A managed spell can be injected like any other: annotate a constructor parameter with its class. Every injection is its own lease, so two handlers get two objects. The holder gives its object back - here the handler's own disposal method releases it, and the handler lives in a request scope (a lesser conduit), so leaving the scope disposes the handler and the connection returns to the ROOT's pool for the next request. The pool belongs to the root and outlives every request scope. Root teardown disposes the idle objects only: an object still out is its holder's, and a release after teardown is refused because the pool left with its root. So give leases back before the root ends - a consumer melded on the root itself that releases at its own disposal meets a pool already gone at root teardown. ## Before you run Use the [Intermediate guide](../../intermediate/index.md) for prerequisite concepts. Run from a checkout with Melder installed and Python 3.14 free-threading selected. The collection download includes the level's local helper modules. ## Run the saved script ```bash python UX_and_AIX_experiences/02_intermediate/47_managed_spell_injection_and_request_scopes.py ``` ```powershell py -3.14t UX_and_AIX_experiences/02_intermediate/47_managed_spell_injection_and_request_scopes.py ``` {download}`Download this collection <../../downloads/intermediate-examples.zip>` · [Source on GitHub](https://github.com/Synaptic724/melder/blob/0895ce795453cd87e35d70665957b4e89aad3317/UX_and_AIX_experiences/02_intermediate/47_managed_spell_injection_and_request_scopes.py) ## Public surface md.Spellbook.bind, md.Existence.managed_spell_quantity, md.Existence.many (disposal_method_names), constructor injection, md.Conduit.enter_lesser_conduit, md.Conduit.meld, md.ReleaseManagedSpell (release, describe), md.Conduit.cleanup ## Code ```{literalinclude} ../../downloads/02_intermediate/47_managed_spell_injection_and_request_scopes.py :language: python :linenos: ``` ## Check the outcome The script contains its own assertions or demonstrated refusal paths. Run it to evaluate those checks against your installed version. The code above is taken directly from the saved file; no run output is invented here. [More intermediate examples](index.md) · [Level guide](../../intermediate/index.md) ## Related guides - [Managed spell pools](../../intermediate/managed-spells.md) ## API contracts - [Spellbook](../../reference/api/binding/spellbook.md) - [Conduit](../../reference/api/resolution/conduit.md) - [Existence](../../reference/api/resolution/existence.md) - [ReleaseManagedSpell](../../reference/api/resolution/releasemanagedspell.md)