mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-16 16:14:28 -04:00
close sqlite3 connections if unused
This commit is contained in:
parent
6aef1dd98d
commit
62089fdb22
1 changed files with 9 additions and 1 deletions
|
@ -1102,7 +1102,15 @@ def setup_django(out_dir: Path=None, check_db=False, config: ConfigDict=CONFIG,
|
||||||
cache.get('test', None)
|
cache.get('test', None)
|
||||||
except django.db.utils.OperationalError:
|
except django.db.utils.OperationalError:
|
||||||
call_command("createcachetable", verbosity=0)
|
call_command("createcachetable", verbosity=0)
|
||||||
|
|
||||||
|
|
||||||
|
# if archivebox gets imported multiple times, we have to close
|
||||||
|
# the sqlite3 whenever we init from scratch to avoid multiple threads
|
||||||
|
# sharing the same connection by accident
|
||||||
|
from django.db import connections
|
||||||
|
for conn in connections.all():
|
||||||
|
conn.close_if_unusable_or_obsolete()
|
||||||
|
|
||||||
sql_index_path = Path(output_dir) / SQL_INDEX_FILENAME
|
sql_index_path = Path(output_dir) / SQL_INDEX_FILENAME
|
||||||
assert sql_index_path.exists(), (
|
assert sql_index_path.exists(), (
|
||||||
f'No database file {SQL_INDEX_FILENAME} found in: {config["OUTPUT_DIR"]} (Are you in an ArchiveBox collection directory?)')
|
f'No database file {SQL_INDEX_FILENAME} found in: {config["OUTPUT_DIR"]} (Are you in an ArchiveBox collection directory?)')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue