Skip to main content

interrupt

Function interrupt 

Source
pub unsafe fn interrupt(con: duckdb_connection)
Expand description

Requests cancellation of whatever con is currently running.

The call itself is non-blocking: it sets ClientContext::interrupted, an atomic<bool> the executor polls, so the running query fails with an interrupt error at its next check rather than immediately. Calling it while no query is running arms nothing โ€” DuckDB clears the flag when a query starts.

ยงSafety

con must be a valid, open duckdb_connection for the duration of this call. It is sound to call this from a different thread than the one running the query โ€” that is the point of the API โ€” but it is not sound to race it against duckdb_disconnect. Prefer OwnedConnection::interrupt_handle, whose lifetime enforces that.