Skip to content

Handle CancelledError in bind_execute_many - #1375

Open
MaciejZet wants to merge 1 commit into
MagicStack:masterfrom
MaciejZet:fix/executemany-cancelled
Open

MaciejZet wants to merge 1 commit into
MagicStack:masterfrom
MaciejZet:fix/executemany-cancelled

Conversation

@MaciejZet

Copy link
Copy Markdown

Fixes #1265

bind_execute_many catches Exception. CancelledError is a BaseException, so a cancelled executemany skips that handler and reaches return await waiter. The server is still in ClientRead, waiting for the rest of the batch, and that waiter never completes. asyncio.gather then hangs.

The cancel path now stores the CancelledError on the waiter and aborts the protocol. The same abort runs when cancellation arrives while the method is already waiting on the server. The connection closes. A timeout still sends the existing fail message and keeps the connection.

Test plan

  • tests.test_cancellation — 5 tests, including a new executemany case that cancels a batch larger than one 128KB write and expects CancelledError within 5 seconds with the connection closed
  • tests.test_execute.TestExecuteMany — 13 tests, including timeout and client-failure cases

This branch has not been deployed

No deployments
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