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
When a task is cancelled while an aiosqlite.Connection object is connecting, the sqlite connection is never closed and is left hanging. Additionally the aiosqlite.Connection threads don't get shut down.
Details
OS: Windows 10 Pro 10.0.19045
Python version: 3.11.5
aiosqlite version: 0.19.0
Can you repro on 'main' branch? Yes
Can you repro in a clean virtualenv? Yes
Repro code:
importasyncioimportaiosqliteasyncdefconnect_to_db():
asyncwithaiosqlite.connect("test.db") asdb:
awaitdb.execute("SELECT value FROM generate_series(0,1000000,1)")
asyncdefmain_loop():
tasks= []
foriinrange(5):
tasks.append(asyncio.create_task(connect_to_db()))
print("Tasks started")
awaitasyncio.sleep(0)
print("Async tick")
fortaskintasks:
task.cancel()
print("Tasks cancelled")
fortaskintasks:
try:
awaittaskexceptasyncio.CancelledError:
continue# This was a debug helper to track open connections# from aiosqlite.core import print_connections_info# print_connections_info()awaitasyncio.sleep(5)
print("Complete")
if__name__=="__main__":
asyncio.run(main_loop())
Expected behavior: File handles for test.db would be released as tasks were successfully cancelled.
Actual behavior: 5 file handles are kept indefinitely for test.db (can be verified with a program such as OpenedFilesView or keeping track of the sqlite connections). Additionally after the event loop stops, the script hangs.
The text was updated successfully, but these errors were encountered:
I suspect there may be other problems when tasks are cancelled, but haven't figured out minimal test cases for them yet. My program was often getting into a state where a series of cancelled write tasks would eventually lock the database indefinitely.
Description
When a task is cancelled while an aiosqlite.Connection object is connecting, the sqlite connection is never closed and is left hanging. Additionally the aiosqlite.Connection threads don't get shut down.
Details
Repro code:
Expected behavior: File handles for test.db would be released as tasks were successfully cancelled.
Actual behavior: 5 file handles are kept indefinitely for test.db (can be verified with a program such as OpenedFilesView or keeping track of the sqlite connections). Additionally after the event loop stops, the script hangs.
The text was updated successfully, but these errors were encountered: