Skip to content

Commit 46cc7e5

Browse files
historian: avoid leaving db lock in place when shutting down
Avoid the error: plugin-historian.py: sqlite3.OperationalError: database is locked
1 parent 8748b61 commit 46cc7e5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

archived/historian/historian.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,10 @@ def publish(self, raw: bytes) -> None:
309309
@plugin.init()
310310
def init(plugin, configuration, options):
311311
print(options)
312-
engine = create_engine(options['historian-dsn'], echo=False)
313-
Base.metadata.create_all(engine)
314-
plugin.engine = engine
315-
Flusher(engine).start()
312+
with create_engine(options['historian-dsn'], echo=False) as engine:
313+
Base.metadata.create_all(engine)
314+
plugin.engine = engine
315+
Flusher(engine).start()
316316

317317

318318
@plugin.method('historian-stats')

0 commit comments

Comments
 (0)