mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
push_notifications: Set more reasonable timeouts.
This commit is contained in:
@@ -20,8 +20,8 @@ from zerver.models import OrgTypeEnum, Realm, RealmAuditLog
|
||||
|
||||
|
||||
class PushBouncerSession(OutgoingSession):
|
||||
def __init__(self) -> None:
|
||||
super().__init__(role="push_bouncer", timeout=30)
|
||||
def __init__(self, timeout: int = 15) -> None:
|
||||
super().__init__(role="push_bouncer", timeout=timeout)
|
||||
|
||||
|
||||
class PushNotificationBouncerError(Exception):
|
||||
@@ -98,9 +98,23 @@ def send_to_push_bouncer(
|
||||
headers = {"User-agent": f"ZulipServer/{ZULIP_VERSION}"}
|
||||
headers.update(extra_headers)
|
||||
|
||||
if endpoint == "server/analytics":
|
||||
# Uploading audit log and/or analytics data can require the
|
||||
# bouncer to do a significant chunk of work in a few
|
||||
# situations; since this occurs in background jobs, set a long
|
||||
# timeout.
|
||||
session = PushBouncerSession(timeout=90)
|
||||
else:
|
||||
session = PushBouncerSession()
|
||||
|
||||
try:
|
||||
res = PushBouncerSession().request(
|
||||
method, url, data=post_data, auth=api_auth, verify=True, headers=headers
|
||||
res = session.request(
|
||||
method,
|
||||
url,
|
||||
data=post_data,
|
||||
auth=api_auth,
|
||||
verify=True,
|
||||
headers=headers,
|
||||
)
|
||||
except (
|
||||
requests.exceptions.Timeout,
|
||||
|
||||
Reference in New Issue
Block a user