Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions monitoring/monitorlib/fetch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import uuid
from dataclasses import dataclass
from enum import Enum
from http.client import RemoteDisconnected
from typing import Self, TypeVar
from urllib.parse import urlparse

Expand Down Expand Up @@ -714,10 +715,21 @@ def build_failing_query(t0) -> Query:
logger.warning(failure_message)
failures.append(failure_message)
except requests.ConnectionError as e:
if "RemoteDisconnected" in str(e):
# This error manifests as:
# ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
# ...and this may be retryable

def context_contains(exception, types) -> bool:
if (
exception.__class__ in types
): # We don't use isinstance, we want exact type
return True

parent = getattr(exception, "__context__", None)

if parent:
return context_contains(parent, types)
else:
return False

if context_contains(e, (RemoteDisconnected, ConnectionResetError)):
retryable = True
else:
retryable = False
Expand Down
Loading