From 9ea408441f527064aeafb5a7076a10a15f2c580c Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 20 Sep 2018 16:15:21 +0100 Subject: [PATCH] Handle exceptions thrown by background tasks Fixes #3921 --- synapse/metrics/background_process_metrics.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/synapse/metrics/background_process_metrics.py b/synapse/metrics/background_process_metrics.py index 167167be0..e5293587e 100644 --- a/synapse/metrics/background_process_metrics.py +++ b/synapse/metrics/background_process_metrics.py @@ -191,6 +191,8 @@ def run_as_background_process(desc, func, *args, **kwargs): try: yield func(*args, **kwargs) + except Exception: + logger.exception("Background process '%s' threw an exception", desc) finally: proc.update_metrics()