Skip to content

Commit da2e6e3

Browse files
Narrow BaseException suppress in _run_sync KI/SystemExit bounded-wait arm
The KI/SystemExit cleanup arm of ``_run_sync`` wrapped ``future.result(timeout=1.0)`` in ``contextlib.suppress(BaseException)``. A SECOND KeyboardInterrupt / SystemExit delivered during the 1-second bounded wait was silently swallowed — denying the user's Ctrl-C escalation from "cancel this op" to "abort the process" for up to 1 second. Mirror the sibling timeout arm's narrow shape: catch ``CancelledError`` + ``TimeoutError`` (cancellation acknowledged), DEBUG-log other ``Exception`` (programming bug in cleanup is observable), and let KI/SystemExit propagate. The original (first) KI is still re-raised by the trailing ``raise`` after the cleanup. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ef3d079 commit da2e6e3

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

src/dqlitedbapi/connection.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,8 +860,27 @@ def _run_sync[T](self, coro: Coroutine[Any, Any, T]) -> T:
860860
dying._invalidate,
861861
InterfaceError("operation interrupted"),
862862
)
863-
with contextlib.suppress(BaseException):
863+
# Narrow suppress: a SECOND KI/SystemExit landing
864+
# inside the 1-second bounded wait must propagate so
865+
# the user's Ctrl-C escalation reaches the process.
866+
# The original (first) KI is still re-raised by the
867+
# trailing ``raise``. CancelledError/TimeoutError
868+
# are absorbed (cancellation acknowledged); other
869+
# ``Exception`` from the cancelled coroutine is
870+
# DEBUG-logged so a programming bug in cleanup is
871+
# observable. Mirrors the timeout arm's narrow shape.
872+
try:
864873
future.result(timeout=1.0)
874+
except (
875+
concurrent.futures.CancelledError,
876+
concurrent.futures.TimeoutError,
877+
):
878+
pass
879+
except Exception:
880+
logger.debug(
881+
"sync KI/SystemExit cleanup: unexpected error during bounded cancel-wait",
882+
exc_info=True,
883+
)
865884
raise
866885
finally:
867886
# Only release if we actually acquired. ``acquired`` is

0 commit comments

Comments
 (0)