mirror of
https://github.com/healthchecks/healthchecks.git
synced 2025-04-07 14:15:34 +00:00
Update rocketchat integration to give up db connection before network IO
This commit is contained in:
parent
81623f067a
commit
ffd40c7c3c
2 changed files with 4 additions and 0 deletions
hc/api
|
@ -10,6 +10,7 @@ from hc.api.models import Channel, Check, Flip, Notification, Ping
|
||||||
from hc.test import BaseTestCase
|
from hc.test import BaseTestCase
|
||||||
|
|
||||||
|
|
||||||
|
@patch("hc.api.transports.close_old_connections", Mock())
|
||||||
class NotifyRocketChatTestCase(BaseTestCase):
|
class NotifyRocketChatTestCase(BaseTestCase):
|
||||||
def setUp(self) -> None:
|
def setUp(self) -> None:
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
|
@ -808,6 +808,9 @@ class RocketChat(HttpTransport):
|
||||||
def notify(self, flip: Flip, notification: Notification) -> None:
|
def notify(self, flip: Flip, notification: Notification) -> None:
|
||||||
if not settings.ROCKETCHAT_ENABLED:
|
if not settings.ROCKETCHAT_ENABLED:
|
||||||
raise TransportError("Rocket.Chat notifications are not 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))
|
self.post(self.channel.value, json=self.payload(flip))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue