Client lifecycle¶
Pick the entry point that matches your runtime. All four manage the same ContextVar — the difference is who owns the client and when it's closed.
lifespan
async
¶
Context manager that owns one AsyncClient for its lifetime.
Builds the client, hands ownership to the orm via :func:init,
drains pools on exit via :func:shutdown.
Source code in src/supabase_orm/_async/_client.py
init
¶
Bind client and transfer ownership: shutdown() will close it.
Returns client for inline composition::
init(await acreate_client(URL, KEY))
Source code in src/supabase_orm/_async/_client.py
shutdown
async
¶
Unbind the app-wide client. Closes it if :func:init registered ownership.
Idempotent; no-op when nothing was bound. Subclient close failures are logged, not raised.
Source code in src/supabase_orm/_async/_client.py
set_client
¶
Bind client as the app-wide default; caller keeps ownership.
shutdown() unbinds but does not close. For ownership transfer use
:func:init.
Source code in src/supabase_orm/_async/_client.py
get_client
¶
Source code in src/supabase_orm/_async/_client.py
use_client
async
¶
Bind client for the duration of the async with block only.
Per-task isolated — concurrent requests don't see each other's overrides.