From 5c44101db380fc1e49908ef47dbb4b773442fd46 Mon Sep 17 00:00:00 2001 From: Valerij Maljulin Date: Jan 20 2020 16:11:22 +0000 Subject: Make a stomp connection to always disconnect regardless of errors This fixes #352 Signed-off-by: Valerij Maljulin --- diff --git a/waiverdb/utils.py b/waiverdb/utils.py index 724e50f..15efa7a 100644 --- a/waiverdb/utils.py +++ b/waiverdb/utils.py @@ -93,8 +93,10 @@ def stomp_connection(): conn = stomp.Connection(**configs['connection']) conn.start() conn.connect(**configs.get('credentials', {})) - yield conn - conn.disconnect() + try: + yield conn + finally: + conn.disconnect() else: raise RuntimeError('stomp was configured to publish messages, ' 'but STOMP_CONFIGS is not configured')