Skip to content

Conversation

ermakov-oleg
Copy link
Contributor

Summary

Adds pool_timeout parameter to Pool and create_pool() to prevent indefinite hangs in pool operations.

Problem

Pool operations could hang indefinitely, particularly during connection cleanup and cancellation (issue #431).

Solution

pool = await asyncpg.create_pool(dsn, pool_timeout=5.0)

# Now safe to call without explicit timeouts
result = await pool.fetch("SELECT 1")
conn = await pool.acquire()  # Uses pool_timeout as fallback

Changes

  • Added pool_timeout parameter with validation (must be > 0 or None)
  • Fallback logic: explicit timeout → pool_timeout → infinite wait
  • Pool convenience methods (fetch, execute, etc.) now respect pool_timeout
  • Full backward compatibility maintained

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