From: Patrick Donnelly Date: Tue, 14 Jul 2026 13:37:48 +0000 (-0400) Subject: script/ptl-tool: add automatic HTTP retry adapter to requests session X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1a1693b6e4a89ed977d9133a17d8dec457d732eb;p=ceph.git script/ptl-tool: add automatic HTTP retry adapter to requests session Long-running local git operations and Redmine API calls can cause the idle keep-alive connection to api.github.com to be closed by the remote server. When the script later attempts to post automated PR comments, it fails with http.client.RemoteDisconnected. Fix this by mounting an urllib3 Retry adapter to the requests.Session, automatically re-establishing dropped connections up to 3 times on transient network or server errors (500, 502, 503, 504). Assisted-by: Gemini Signed-off-by: Patrick Donnelly --- diff --git a/src/script/ptl-tool.py b/src/script/ptl-tool.py index a602c025997..70602d3c370 100755 --- a/src/script/ptl-tool.py +++ b/src/script/ptl-tool.py @@ -69,6 +69,8 @@ except ImportError: try: import requests + from requests.adapters import HTTPAdapter + from urllib3.util.retry import Retry except ImportError: MISSING_DEPS.append("requests") @@ -1927,6 +1929,14 @@ def build_branch(args): merge_branch_name = args.merge_branch_name session = requests.Session() + retries = Retry( + total=3, + backoff_factor=1, + status_forcelist=[500, 502, 503, 504], + raise_on_status=False + ) + session.mount("https://", HTTPAdapter(max_retries=retries)) + session.mount("http://", HTTPAdapter(max_retries=retries)) if label: # Check the label format