Skip to content

End an interrupted query in a kernel as Query interrupted - #812

Merged
evertlammerts merged 4 commits into
duckdb:mainfrom
ewoerd:fix-jupyter-progress-display
Dec 3, 2026
Merged

evertlammerts merged 4 commits into
duckdb:mainfrom
ewoerd:fix-jupyter-progress-display

Conversation

@evertlammerts

Copy link
Copy Markdown
Member

In a Jupyter kernel, an interrupt that arrives while the progress widget shows ends the query with the wrong exception:

con = duckdb.connect()
con.execute("SELECT sum(a.range * b.range) FROM range(100000000) a, range(4) b").fetchall()
# interrupted: duckdb.Error: KeyboardInterrupt:
# without the widget: RuntimeError: Query interrupted

The widget's update runs Python on the query's thread after every task, so Python raises the pending SIGINT inside the widget's code. The display let that KeyboardInterrupt fail the query as an ordinary error, and the client's own interrupt check never saw the signal. Update() now sets the signal again and returns, so that check ends the query with RuntimeError: Query interrupted. Every other Python error of the widget still fails the statement as before.

The widget also got only its style: an extra pair of parentheses made its keyword arguments one comma expression, so min and max were dropped. They are now passed. Users see no difference, as 0 and 100 are the ipywidgets defaults.

A cursor still shows no progress in a kernel. Releasing the widget under the GIL and taking the GIL through the client's shutdown gate are left to separate work.

The new tests/fast/api/test_jupyter_progress_bar.py starts a real kernel and reads the widget messages. It uses ipykernel and ipywidgets, now test dependencies. The tests cover the arguments, an interrupt from a timer and one raised inside the widget, one widget per statement that ends at 100, a query that fails midway, a widget that raises, and a clean exit. The arguments and interrupt tests fail on the merge base.

The release line v2.0-cyanoptera has the same two defects, and the fix should be ported there.

@evertlammerts
evertlammerts merged commit 7a66d1a into duckdb:main Dec 3, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant