Skip to content

Avoid initialization race in pool inactivity test - #1365

Merged
elprans merged 1 commit into
masterfrom
fix-pool-test-flakes
Sep 20, 2026
Merged

elprans merged 1 commit into
masterfrom
fix-pool-test-flakes

Conversation

@elprans

@elprans elprans commented Sep 20, 2026

Copy link
Copy Markdown
Member

Pool connections start their idle timers as soon as they connect. If
opening the second connection takes longer than 200 ms, the first can
expire before pool initialization finishes. This makes the initial
holder assertions in test_pool_max_inactive_time_05 fail
intermittently.

Register termination listeners through the init callback and wait for
both connections to close with a bounded timeout. Leave both connections
unacquired and verify their creation, closure, and holder cleanup. This
accepts expiry during initialization while still detecting missing idle
cleanup, without relying on fixed sleeps.

Pool connections start their idle timers as soon as they connect. If
opening the second connection takes longer than 200 ms, the first can
expire before pool initialization finishes. This makes the initial
holder assertions in `test_pool_max_inactive_time_05` fail
intermittently.

Register termination listeners through the init callback and wait for
both connections to close with a bounded timeout. Leave both connections
unacquired and verify their creation, closure, and holder cleanup. This
accepts expiry during initialization while still detecting missing idle
cleanup, without relying on fixed sleeps.
Copilot AI lite review requested due to automatic review settings September 20, 2026 00:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The test reliably handles initialization expiry and verifies cleanup.

Review effort: Lite
Findings: None

What changed in this PR

Updates the pool inactivity test to avoid initialization timing races and reliably verify cleanup.

Changes:

  • Register termination listeners during initialization.
  • Wait for both idle connections to close with a bounded timeout.
  • Verify connection closure and holder cleanup.
File Summary
tests/​test_pool.py Makes the inactivity test race-resistant and validates cleanup.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@elprans
elprans merged commit 5bbd737 into master Sep 20, 2026
48 checks passed
@elprans
elprans deleted the fix-pool-test-flakes branch September 20, 2026 00:45
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.

2 participants