Currently, the threads spawned by aiosqlite's Connection are non-daemon threads, so if you don't explicitly close the connection, the program will stay alive after the main thread exits.
import sqlite3
def create_db():
db = sqlite3.connect('../database/partners_list.db')
create_db()
In my use case, I want to use aiosqlite with Quart, but because I don't want to create a database connection + thread for every request, I will do all my databasing with a single, global connection. However, I'm not sure when the web server will exit and I don't want the program to hang if the database connection hasn't been explicitly closed.
Description
Currently, the threads spawned by aiosqlite's Connection are non-daemon threads, so if you don't explicitly close the connection, the program will stay alive after the main thread exits.
The following aiosqlite code will never exit:
But the equivalent sqlite code does exit:
In my use case, I want to use aiosqlite with Quart, but because I don't want to create a database connection + thread for every request, I will do all my databasing with a single, global connection. However, I'm not sure when the web server will exit and I don't want the program to hang if the database connection hasn't been explicitly closed.
Details