-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Aiosqlite leaves thread hanging #290
Comments
I can’t replicate this with the example code. Are you sure your “long running db updates” have actually completed before pressing ctrl-c? Can you provide more insight on what that long running functionality entails? |
Hello |
I have found that it happens when you have multiple connections (aka multiple threads). import aiosqlite
for each connection a separate thread is created. The actual code makes thousands of inserts updates and deletes to disk based db connection, but I ensure to call db.close() of each db in my finally block. The program never really exits and the shell hangs and ctrl+c yields that output |
Got hanging by the following code at MacOS with python3.10 and aiosqlite==0.20.0 import asyncio
from contextlib import asynccontextmanager
import aiosqlite
@asynccontextmanager
async def open_db():
async with aiosqlite.connect("db.sqlite3"):
yield
@asynccontextmanager
async def nest_open():
async with open_db():
yield
async def gen():
async with nest_open():
yield
async def main():
async for _ in gen():
raise TypeError()
asyncio.run(main()) Related issue #306 |
I import this in a script and call
run
usingasyncio.run(run())
. It finishes but the program never exits because the thread does not get stopped and ctrl+c spits following.^CException ignored in: <module 'threading' from '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/threading.py'> Traceback (most recent call last): File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/threading.py", line 1448, in _shutdown lock.acquire() KeyboardInterrupt:
The text was updated successfully, but these errors were encountered: