From 130e954b9f6552f6d968e6a241848045eb258054 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Fri, 12 Jul 2024 15:06:11 +0200 Subject: [PATCH] server: ignore exceptions in the Watcher loop This is a very poor hack, but we don't face exceptions too frequently here. Let's restart if e.g. this happens: Traceback (most recent call last): File "/usr/lib64/python3.12/site-packages/sqlalchemy/engine/base.py", line 1910, in _execute_context self.dialect.do_execute( File "/usr/lib64/python3.12/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute cursor.execute(statement, parameters) sqlite3.OperationalError: database is locked --- resallocserver/manager.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/resallocserver/manager.py b/resallocserver/manager.py index 35a5b7a..f00fd59 100644 --- a/resallocserver/manager.py +++ b/resallocserver/manager.py @@ -453,7 +453,14 @@ def loop(self): def run(self): while True: - self.loop() + try: + self.loop() + except: # pylint: disable=bare-except + # We are a daemon thread that nobody restarts in case of + # unexpected failure, so let's try to recover :shrug:. If the + # parent dies, we get killed without any announcement, sounds + # fair. + pass time.sleep(app.config["sleeptime"] / 2)