diff --git a/hc/api/tests/test_notify_rocketchat.py b/hc/api/tests/test_notify_rocketchat.py index 70ee112d..91580775 100644 --- a/hc/api/tests/test_notify_rocketchat.py +++ b/hc/api/tests/test_notify_rocketchat.py @@ -10,6 +10,7 @@ from hc.api.models import Channel, Check, Flip, Notification, Ping from hc.test import BaseTestCase +@patch("hc.api.transports.close_old_connections", Mock()) class NotifyRocketChatTestCase(BaseTestCase): def setUp(self) -> None: super().setUp() diff --git a/hc/api/transports.py b/hc/api/transports.py index 47832226..014d72ac 100644 --- a/hc/api/transports.py +++ b/hc/api/transports.py @@ -808,6 +808,9 @@ class RocketChat(HttpTransport): def notify(self, flip: Flip, notification: Notification) -> None: if not settings.ROCKETCHAT_ENABLED: raise TransportError("Rocket.Chat notifications are not enabled.") + + # Give up database connection before potentially long network IO: + close_old_connections() self.post(self.channel.value, json=self.payload(flip))