Skip to content

Prevent stuck cancel requests from blocking close - #1349

Draft
aryansk wants to merge 1 commit into
MagicStack:masterfrom
aryansk:fix/1326-close-cancel-task
Draft

Prevent stuck cancel requests from blocking close#1349
aryansk wants to merge 1 commit into
MagicStack:masterfrom
aryansk:fix/1326-close-cancel-task

Conversation

@aryansk

@aryansk aryansk commented Aug 16, 2026

Copy link
Copy Markdown

Summary

Prevent an in-flight PostgreSQL CancelRequest task from keeping Connection.close(timeout=...) alive beyond the requested graceful-close timeout.

Changes

  • cancel outstanding background cancellation tasks before beginning the graceful protocol close
  • rely on the existing cancellation-task cleanup path to discard those tasks and resolve their waiters
  • leave normal connection close behavior unchanged when no cancellation is pending

Test plan

Use the self-contained fake-server reproducer from #1326: after a command timeout creates a held-open cancel connection, conn.close(timeout=2) should no longer wait indefinitely.

Fixes #1326

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant