From 9e4631f85fd30b6abc42afb9584aef0130ca8841 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 While we ignore such exceptions now, we at least log out the exception traceback for later analysis. --- resallocserver/manager.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/resallocserver/manager.py b/resallocserver/manager.py index 35a5b7a..353d650 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. + app.log.exception("Watcher's logic raised exception, ignoring.") time.sleep(app.config["sleeptime"] / 2)