Skip to content

Commit deafb81

Browse files
endothermicdevcdecker
authored andcommitted
historian: avoid leaving db lock in place when shutting down
Avoid the error: plugin-historian.py: sqlite3.OperationalError: database is locked
1 parent 53cb203 commit deafb81

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

archived/historian/historian.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,13 @@ 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+
try:
313+
engine = create_engine(options['historian-dsn'], echo=False)
314+
Base.metadata.create_all(engine)
315+
plugin.engine = engine
316+
Flusher(engine).start()
317+
finally:
318+
engine.dispose()
316319

317320

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

0 commit comments

Comments
 (0)