Skip to content

Add Pool.on_acquire hook with AcquireEvent#1320

Open
janbjorge wants to merge 2 commits into
MagicStack:masterfrom
janbjorge:feature/pool-on-acquire-hook
Open

Add Pool.on_acquire hook with AcquireEvent#1320
janbjorge wants to merge 2 commits into
MagicStack:masterfrom
janbjorge:feature/pool-on-acquire-hook

Conversation

@janbjorge
Copy link
Copy Markdown

Adds an optional on_acquire callback to Pool / create_pool, mirroring the existing setup/init/reset style. The callback is invoked synchronously with an AcquireEvent(wait_seconds, size, idle, max_size) after every successful Pool.acquire dispatch. Lets applications detect pool saturation (long wait, idle == 0) without subclassing the pool or wrapping every callsite. Callback exceptions are logged and suppressed. No behavior change when unused.

janbjorge added 2 commits May 14, 2026 18:28
Adds an optional `on_acquire` callback to `Pool` / `create_pool`,
mirroring the existing setup/init/reset style. The callback is invoked
synchronously with an `AcquireEvent(wait_seconds, size, idle, max_size)`
after every successful `Pool.acquire` dispatch. Lets applications detect
pool saturation (long wait, idle == 0) without subclassing the pool or
wrapping every callsite. Callback exceptions are logged and suppressed.
No behavior change when unused.
Caller branches in `_acquire` so `_fire_on_acquire` does not need a
redundant None check.
@janbjorge janbjorge marked this pull request as ready for review May 14, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant