Open ErikKalkoken opened 1 year ago
@amyreese Currently experiencing this on py312 / aiosqlite v0.20.0 too. @ErikKalkoken PS: On py311 / aiosqlite v0.20.0, I did not experience this error.
Reviewing the code, the event flows is this:
loop1
.Connection
instance.
Connection
's own thread has also an asyncio event loop. Let's call this loop loop2
Connection
instance
loop2
loop1
for (so far) unknown reason.
loop2
.future
's result.
set_result
/ set_exception
) since the function can't be executed on the future's binded loop loop1
because loop1
is closed.loop1
's execution contextTherefore, any transaction queue item results must forwarded to loop2
before await connection.close()
returns.
Description
I am current building a persistent queue library based on aiosqlite and think I might have found a bug.
When a task is still trying to perform SQL queries during shutdown it will raise the following exception:
In order to allow for a graceful shutdown of a service I think it should log the SQL statement that failed, instead of producing this exception.
Here is a minimal code example to reproduce this behavior:
Details