Skip to content

Ctrl-C does not stop a running query #62

Description

@zahariash

This work was produced with the help of language models.

Python runs its SIGINT handler only between bytecodes. While the main thread waits in the engine for execute(), query() or query_as_arrow(), Ctrl-C has no effect until the query finishes. With SIGINT sent 1 s into a query that runs for 15-18 s, KeyboardInterrupt appeared only when the query finished, 15-18 s after it started.

import ladybug as lb

conn = lb.Connection(lb.Database(":memory:"))
# Runs for many seconds; press Ctrl-C while it does.
conn.execute("WITH range(1, 40000) AS r UNWIND r AS x UNWIND r AS y RETURN sum(x * y)")

Expected: the query is interrupted and KeyboardInterrupt is raised promptly; the connection stays usable.
Actual: the query runs to the end; KeyboardInterrupt is raised only after it has finished.

Reproduced on main (548c183) with CPython 3.12. The fix covers the pybind backend on POSIX; the C-API backend calls the engine through ctypes and is not covered.

Fix: #66

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions