Skip to content

Commit

Permalink
Add daemonic option
Browse files Browse the repository at this point in the history
Normally, the Connection thread prevents program exit unless
close() is explicitly closed, unless `deaemonic=True` is passed.

It defaults to `False` which means aiosqlite's behaviour remains unaffected.

This PR would also address issues which have been opened for some time now:
omnilib#74
omnilib#299
  • Loading branch information
smanolloff committed Oct 28, 2024
1 parent 463a2e8 commit 2a98705
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions aiosqlite/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ def __init__(
connector: Callable[[], sqlite3.Connection],
iter_chunk_size: int,
loop: Optional[asyncio.AbstractEventLoop] = None,
daemonic: bool = False,
) -> None:
super().__init__()
super().__init__(daemon=daemonic)
self._running = True
self._connection: Optional[sqlite3.Connection] = None
self._connector = connector
Expand Down Expand Up @@ -371,6 +372,7 @@ def connect(
*,
iter_chunk_size=64,
loop: Optional[asyncio.AbstractEventLoop] = None,
daemonic: bool = False,
**kwargs: Any,
) -> Connection:
"""Create and return a connection proxy to the sqlite database."""
Expand All @@ -391,4 +393,4 @@ def connector() -> sqlite3.Connection:

return sqlite3.connect(loc, **kwargs)

return Connection(connector, iter_chunk_size)
return Connection(connector, iter_chunk_size, daemonic)

0 comments on commit 2a98705

Please sign in to comment.