Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
tornado: Add a retry with backoff to django-to-tornado requests.
Alex Vandiverbb754e09028a
diff --git a/zerver/tornado/django_api.py b/zerver/tornado/django_api.pyindex 1e563797d17..60a1cd41c21 100644--- a/zerver/tornado/django_api.py+++ b/zerver/tornado/django_api.py@@ -5,6 +5,8 @@ from typing import Any, Dict, Iterable, List, Mapping, Optional, Sequence, Unionimport requestsimport ujsonfrom django.conf import settings+from requests.adapters import HTTPAdapter+from requests.packages.urllib3.util.retry import Retryfrom zerver.lib.queue import queue_json_publishfrom zerver.models import Client, Realm, UserProfile@@ -20,6 +22,15 @@ def requests_client() -> requests.Session:# Disable trusting the environment, so requests don't# go through any env-configured external proxy.c.trust_env = False++ # During restarts, the tornado server may be down briefly+ retry = Retry(+ total=3,+ backoff_factor=1,+ )+ adapter = HTTPAdapter(max_retries=retry)+ for scheme in ("https://", "http://"):+ c.mount(scheme, adapter)return cdef request_event_queue(user_profile: UserProfile, user_client: Client, apply_markdown: bool,