-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
It's very unhealthy for the database connection pools to always establish a new connection on each run. Also it's pretty bad to have a database connection always running (since there is maximum limit).
Hence, I would like to have a feature in the interval-py project to have a shared context for the actions, that you can access through the io object.
Imagine something like this (API borrowed from FastAPI):
@interval.on_event("startup")
async def startup_event(io: IO):
"""
Connect to the db.
"""
io.state['pool'] = await create_pool(...)Which then can be used generally:
@interval.action
async def any_action(io: IO):
async with io.state['pool'].acquire() as con:
await con.fetch('SELECT 1')
return f"Hello {name}"Metadata
Metadata
Assignees
Labels
No labels