You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AsyncConnection: a cancelled execute() returns None instead of raising #59
This work was produced with the help of language models.
AsyncConnection.execute() catches asyncio.CancelledError, interrupts the connection and returns None. A cancelled task therefore looks like a normal return: task.cancelled() is false, loops keep running after cancellation, and asyncio.wait_for() / asyncio.timeout() return None instead of raising TimeoutError.
In the same code path:
Cancelling a task that is still waiting for a free connection interrupts whatever query runs on that connection, i.e. another task's query.
The connection counter is released when the awaiting task exits, while the query may still be running.
execute() with a PreparedStatement from a connection outside the pool raises UnboundLocalError.
importasyncio, ladybugaslbasyncdefmain():
ac=lb.AsyncConnection(lb.Database(":memory:"))
q="WITH range(1, 30000) AS r UNWIND r AS x UNWIND r AS y RETURN sum(x * y)"print(awaitasyncio.wait_for(ac.execute(q), 0.5))
asyncio.run(main())
Expected:asyncio.TimeoutError after 0.5 s. Actual: prints None.
Reproduced with the ladybug==0.21.2 wheel on CPython 3.13.16 and 3.14.8, and on main (548c183) with CPython 3.12.
Activity