{"id":124162,"date":"2026-11-18T16:48:55","date_gmt":"2026-11-18T08:48:55","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/124162.html"},"modified":"2026-11-18T16:48:55","modified_gmt":"2026-11-18T08:48:55","slug":"%e8%af%b4%e5%a5%bd%e9%87%8d%e8%af%95%e4%b8%89%e6%ac%a1%ef%bc%8c%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%94%b6%e5%88%b0%e5%9b%9b%e4%b8%8b","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/124162.html","title":{"rendered":"\u8bf4\u597d\u91cd\u8bd5\u4e09\u6b21\uff0c\u670d\u52a1\u5668\u6536\u5230\u56db\u4e0b"},"content":{"rendered":"<p>        \/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/<br \/>\n        #content_views .toc,<br \/>\n        \/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/<br \/>\n        #content_views.markdown_views &gt; p:empty:has(+ .toc),<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty,<br \/>\n        \/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/<br \/>\n        #content_views.htmledit_views #main-toc,<br \/>\n        #content_views.htmledit_views #hr-toc,<br \/>\n        #content_views.htmledit_views p[id*=\\&#8221;-toc\\&#8221;] {<br \/>\n          display: none !important;<br \/>\n        }<br \/>\n        \/* \u76ee\u5f55\u53bb\u6389\u540e\uff0c\u7d27\u8ddf\u7684\u9996\u4e2a\u6807\u9898\u4e0d\u518d\u591a\u51fa\u4e00\u5757\u4e0a\u8fb9\u8ddd *\/<br \/>\n        #content_views.markdown_views &gt; .toc + h1,<br \/>\n        #content_views.markdown_views &gt; .toc + h2,<br \/>\n        #content_views.markdown_views &gt; .toc + h3,<br \/>\n        #content_views.markdown_views &gt; .toc + h4,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h1,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h2,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h3,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h4 {<br \/>\n          margin-top: 0 !important;<br \/>\n        }<\/p>\n<p>requests \u91cd\u8bd5\u5b9e\u6d4b&#xff1a;Retry(total&#061;3) \u4e3a\u4ec0\u4e48\u6253\u56db\u6b21\u3001status_forcelist \u4e0d\u914d\u4e3a\u4ec0\u4e48\u7b49\u4e8e\u6ca1\u91cd\u8bd5\u3001POST \u9ed8\u8ba4\u4e3a\u4ec0\u4e48\u4e0d\u91cd\u8bd5\u3001backoff_factor \u4e3a\u4ec0\u4e48\u7b2c\u4e00\u6b21\u4e0d\u7b49&#xff08;urllib3 2.7 \/ Python 3.13&#xff09;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261118084852-6afd667471f6e.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>\u96f6\u3001\u5148\u8bf4\u7ed3\u8bba<\/h3>\n<p>\u7ed9 HTTP \u5ba2\u6237\u7aef\u8bbe\u4e86 Retry(total&#061;3)&#xff0c;\u6309\u5b57\u9762\u7406\u89e3\u662f\u300c\u6700\u591a\u4e09\u6b21\u8bf7\u6c42\u300d\u3002\u672c\u5730\u8d77\u4e00\u4e2a\u4f1a\u8fd4\u56de 503 \u7684\u670d\u52a1&#xff0c;\u4e00\u6b21\u8c03\u7528\u4e4b\u540e\u6570\u4e86\u6570&#xff0c;\u670d\u52a1\u7aef\u6536\u5230\u56db\u6b21\u3002<\/p>\n<p>total \u6570\u7684\u662f\u91cd\u8bd5&#xff0c;\u4e0d\u662f\u8bf7\u6c42\u3002\u7b2c\u4e00\u6b21\u662f\u539f\u59cb\u8bf7\u6c42&#xff0c;\u540e\u9762\u4e09\u6b21\u624d\u662f\u91cd\u8bd5&#xff0c;\u6240\u4ee5 1 \u52a0 3 \u7b49\u4e8e 4\u3002\u66f4\u9ebb\u70e6\u7684\u662f\u53cd\u8fc7\u6765\u90a3\u79cd\u60c5\u51b5&#xff1a;\u53ea\u5199 Retry(total&#061;3) \u800c\u4e0d\u7ed9 status_forcelist&#xff0c;\u670d\u52a1\u7aef\u53ea\u6536\u5230\u4e00\u6b21\u8bf7\u6c42&#xff0c;\u5ba2\u6237\u7aef\u76f4\u63a5\u62ff\u7740 503 \u56de\u6765\u4e86&#xff0c;\u91cd\u8bd5\u538b\u6839\u6ca1\u53d1\u751f&#xff0c;\u4e5f\u6ca1\u6709\u4efb\u4f55\u62a5\u9519\u3002<\/p>\n<p>\u4e0b\u9762\u5168\u90e8\u5728 Python 3.13.12\u3001requests 2.34.2\u3001urllib3 2.7.0 \u4e0a\u5b9e\u6d4b\u3002\u505a\u6cd5\u662f\u672c\u673a\u8d77\u4e00\u4e2a HTTP \u670d\u52a1&#xff0c;\u6bcf\u6b21\u8bf7\u6c42\u771f\u5b9e\u8ba1\u6570&#xff0c;\u4e0d\u662f\u6a21\u62df\u63a8\u6f14&#xff1b;120 \u6b21\u8c03\u7528\u7684\u72b6\u6001\u5e8f\u5217\u7531\u56fa\u5b9a\u79cd\u5b50\u751f\u6210&#xff0c;\u4e0d\u662f\u771f\u5b9e\u7ebf\u4e0a\u6d41\u91cf\u3002\u5b98\u65b9\u6587\u6863\u6838\u7684\u662f urllib3 2.7.0 \u7684\u5bf9\u5e94\u7248\u672c\u9875&#xff0c;\u4e0e\u672c\u673a\u7248\u672c\u4e00\u81f4&#xff0c;\u8fd9\u6b21\u6ca1\u6709\u7248\u672c\u9519\u914d\u3002\u6240\u6709\u6570\u5b57\u5220\u6389\u539f\u59cb\u8fd4\u56de\u53ef\u4ee5\u5b8c\u6574\u91cd\u8dd1\u3002<\/p>\n<h3>\u4e00\u3001\u4e09\u6b21\u91cd\u8bd5&#xff0c;\u4e3a\u4ec0\u4e48\u662f\u56db\u6b21\u8bf7\u6c42&#xff1f;<\/h3>\n<p>\u5148\u770b\u540c\u4e00\u7c7b\u914d\u7f6e\u6362\u4e00\u4e2a\u53c2\u6570\u4e4b\u540e&#xff0c;\u8bf7\u6c42\u6b21\u6570\u80fd\u5dee\u591a\u5c11&#xff1a;<\/p>\n<table>\n<tr>\u914d\u7f6e\u5b9e\u9645\u8bf7\u6c42\u6b21\u6570\u6700\u7ec8\u7ed3\u679c<\/tr>\n<tbody>\n<tr>\n<td>total&#061;3 &#xff0b; status_forcelist&#061;[503]<\/td>\n<td>4<\/td>\n<td>\u629b RetryError<\/td>\n<\/tr>\n<tr>\n<td>total&#061;3 \u4e0d\u914d\u540d\u5355<\/td>\n<td>1<\/td>\n<td>\u76f4\u63a5\u8fd4\u56de 503<\/td>\n<\/tr>\n<tr>\n<td>total&#061;0 &#xff0b; \u540d\u5355<\/td>\n<td>1<\/td>\n<td>\u629b RetryError<\/td>\n<\/tr>\n<tr>\n<td>raise_on_status&#061;False<\/td>\n<td>4<\/td>\n<td>\u8fd4\u56de 503&#xff0c;\u4e0d\u629b\u5f02\u5e38<\/td>\n<\/tr>\n<tr>\n<td>POST&#xff0c;\u9ed8\u8ba4\u65b9\u6cd5\u96c6<\/td>\n<td>1<\/td>\n<td>\u76f4\u63a5\u8fd4\u56de 503<\/td>\n<\/tr>\n<tr>\n<td>POST&#xff0c;allowed_methods&#061;None<\/td>\n<td>4<\/td>\n<td>\u629b RetryError<\/td>\n<\/tr>\n<tr>\n<td>status&#061;1<\/td>\n<td>2<\/td>\n<td>\u629b RetryError<\/td>\n<\/tr>\n<tr>\n<td>\u54cd\u5e94\u672c\u6765\u5c31\u662f 200<\/td>\n<td>1<\/td>\n<td>\u6b63\u5e38\u8fd4\u56de<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>total&#061;0 \u90a3\u4e00\u884c\u503c\u5f97\u505c\u4e00\u4e0b&#xff1a;\u8bbe\u6210\u96f6\u6b21\u91cd\u8bd5&#xff0c;\u8bf7\u6c42\u786e\u5b9e\u53ea\u6253\u4e86\u4e00\u6b21&#xff0c;\u4f46\u5ba2\u6237\u7aef\u629b\u7684\u662f RetryError\u3002\u56e0\u4e3a\u53ea\u8981\u72b6\u6001\u7801\u843d\u5728\u540d\u5355\u91cc&#xff0c;\u91cd\u8bd5\u903b\u8f91\u5c31\u88ab\u89e6\u53d1\u4e86&#xff0c;\u4e00\u8fdb\u53bb\u53d1\u73b0\u9884\u7b97\u662f\u96f6&#xff0c;\u4e8e\u662f\u4ee5\u300c\u91cd\u8bd5\u8017\u5c3d\u300d\u6536\u573a\u3002\u5b83\u4e0d\u662f\u6ca1\u91cd\u8bd5&#xff0c;\u662f\u91cd\u8bd5\u4e00\u6b21\u90fd\u6ca1\u88ab\u5141\u8bb8\u3002<\/p>\n<p>\u5b98\u65b9\u6587\u6863\u5bf9 total \u7684\u539f\u6587\u662f Total number of retries to allow. Takes precedence over other counts.&#xff0c;\u540e\u9762\u8fd8\u5199\u4e86 Set to 0 to fail on the first retry.\u3002\u5b57\u9762\u4e00\u76f4\u5f88\u6e05\u695a&#xff0c;\u662f\u6211\u4eec\u4e60\u60ef\u628a\u300c\u91cd\u8bd5\u6b21\u6570\u300d\u8bfb\u6210\u300c\u8bf7\u6c42\u6b21\u6570\u300d\u3002<\/p>\n<h3>\u4e8c\u3001\u4e0d\u914d status_forcelist \u4f1a\u600e\u6837&#xff1f;<\/h3>\n<p>\u8fd9\u662f\u6574\u7bc7\u91cc\u6700\u5bb9\u6613\u9020\u6210\u4e8b\u6545\u7684\u4e00\u6761\u3002\u9ed8\u8ba4\u914d\u7f6e\u4e0b&#xff0c;urllib3 \u53ea\u4f1a\u5bf9\u8fde\u63a5\u7c7b\u9519\u8bef\u91cd\u8bd5&#xff0c;\u4e0d\u4f1a\u56e0\u4e3a\u4f60\u62ff\u5230\u4e00\u4e2a 500 \u6216 503 \u5c31\u518d\u53d1\u4e00\u6b21\u3002\u8981\u8ba9\u5b83\u5bf9\u72b6\u6001\u7801\u91cd\u8bd5&#xff0c;\u5fc5\u987b\u663e\u5f0f\u7ed9 status_forcelist\u3002<\/p>\n<p>\u6587\u6863\u539f\u6587\u5199\u5f97\u5f88\u76f4\u767d&#xff1a;By default, this is disabled with None.&#xff0c;\u5e76\u4e14\u91cd\u8bd5\u7684\u89e6\u53d1\u6761\u4ef6\u662f\u300c\u8bf7\u6c42\u65b9\u6cd5\u5728 allowed_methods \u91cc&#xff0c;\u4e14\u54cd\u5e94\u72b6\u6001\u7801\u5728 status_forcelist \u91cc\u300d&#xff0c;\u4e24\u4e2a\u6761\u4ef6\u7f3a\u4e00\u4e0d\u53ef\u3002<\/p>\n<p>\u4e3a\u4ec0\u4e48\u9ed8\u8ba4\u5173\u7740&#xff1f;\u56e0\u4e3a\u4e00\u4e2a 5xx \u5e76\u4e0d\u4ee3\u8868\u670d\u52a1\u7aef\u6ca1\u5904\u7406\u3002\u8ba2\u5355\u53ef\u80fd\u5df2\u7ecf\u5199\u8fdb\u53bb\u4e86&#xff0c;\u53ea\u662f\u56de\u5305\u4e22\u4e86&#xff0c;\u8fd9\u65f6\u5019\u518d\u53d1\u4e00\u6b21\u5c31\u662f\u91cd\u590d\u5199\u5165\u3002\u8fd9\u4e2a\u9ed8\u8ba4\u503c\u662f\u4fdd\u62a4&#xff0c;\u4e0d\u662f\u5077\u61d2\u3002\u6240\u4ee5\u770b\u5230\u300c\u914d\u4e86 total \u5374\u6ca1\u91cd\u8bd5\u300d&#xff0c;\u522b\u6025\u7740\u5f53\u6210\u5e93\u7684 bug&#xff0c;\u5148\u95ee\u4e00\u53e5&#xff1a;\u6211\u5230\u5e95\u5e0c\u671b\u5b83\u5bf9\u4ec0\u4e48\u91cd\u8bd5\u3002<\/p>\n<h3>\u4e09\u3001POST \u4e3a\u4ec0\u4e48\u4e00\u6b21\u90fd\u4e0d\u91cd\u8bd5&#xff1f;<\/h3>\n<p>\u9ed8\u8ba4\u5141\u8bb8\u91cd\u8bd5\u7684\u65b9\u6cd5\u96c6\u5408&#xff0c;\u6211\u76f4\u63a5\u628a\u7c7b\u5c5e\u6027\u8bfb\u51fa\u6765&#xff1a;DEFAULT_ALLOWED_METHODS &#061; frozenset({&#039;DELETE&#039;, &#039;GET&#039;, &#039;HEAD&#039;, &#039;OPTIONS&#039;, &#039;PUT&#039;, &#039;TRACE&#039;})&#xff0c;\u516d\u4e2a&#xff0c;\u6ca1\u6709 POST\u3002\u6587\u6863\u7684\u8bf4\u6cd5\u662f\u9ed8\u8ba4\u53ea\u91cd\u8bd5\u5e42\u7b49\u65b9\u6cd5&#xff0c;\u8bbe\u6210 None \u624d\u5bf9\u4efb\u610f\u65b9\u6cd5\u91cd\u8bd5\u3002<\/p>\n<p>\u5b9e\u6d4b&#xff1a;\u540c\u4e00\u4e2a\u8fd4\u56de 503 \u7684\u670d\u52a1&#xff0c;\u7528 POST \u6253\u8fc7\u53bb\u53ea\u6536\u5230\u4e00\u6b21\u8bf7\u6c42&#xff1b;\u628a allowed_methods \u8bbe\u6210 None \u4e4b\u540e\u53d8\u6210\u56db\u6b21\u3002<\/p>\n<p>\u8fd9\u91cc\u8981\u7ed9\u4e00\u53e5\u53cd\u65b9\u5411\u7684\u63d0\u9192&#xff1a;\u9ed8\u8ba4\u503c\u5728\u4fdd\u62a4\u4f60&#xff0c;\u522b\u4e3a\u4e86\u300c\u8ba9\u91cd\u8bd5\u751f\u6548\u300d\u968f\u624b\u653e\u5f00\u3002\u5199\u5165\u7c7b\u63a5\u53e3\u4e00\u65e6\u5141\u8bb8\u81ea\u52a8\u91cd\u8bd5&#xff0c;\u524d\u9762\u7b2c\u4e8c\u8282\u8bf4\u7684\u91cd\u590d\u526f\u4f5c\u7528\u5c31\u771f\u4f1a\u843d\u5230\u5e93\u91cc\u3002\u771f\u8981\u91cd\u8bd5 POST&#xff0c;\u524d\u63d0\u662f\u63a5\u53e3\u672c\u8eab\u6709\u5e42\u7b49\u952e&#xff0c;\u6216\u8005\u53ea\u653e\u5f00\u8fde\u63a5\u7c7b\u9519\u8bef\u3001\u4e0d\u628a 5xx \u653e\u8fdb\u540d\u5355\u3002\u8fd9\u4e24\u4ef6\u4e8b\u90fd\u4e0d\u8be5\u9760\u6539\u4e00\u4e2a None \u89e3\u51b3\u3002<\/p>\n<h3>\u56db\u3001total \u4e0e status\u3001connect \u8c01\u8bf4\u4e86\u7b97&#xff1f;<\/h3>\n<p>total \u662f\u603b\u9884\u7b97&#xff0c;\u4f46 connect\u3001read\u3001status\u3001other \u5404\u6709\u5404\u7684\u72ec\u7acb\u8ba1\u6570\u3002\u6587\u6863\u5bf9 total \u5199\u7684\u662f takes precedence over other counts&#xff0c;\u53e6\u5916\u56db\u7c7b\u5206\u522b\u5bf9\u5e94\u8fde\u63a5\u524d\u9519\u8bef\u3001\u8bfb\u53d6\u9519\u8bef\u3001\u72b6\u6001\u7801\u91cd\u8bd5\u3001\u5176\u5b83\u9519\u8bef\u3002<\/p>\n<table>\n<tr>\u914d\u7f6e\u5b9e\u9645\u8bf7\u6c42\u6b21\u6570\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>total&#061;3, status&#061;1<\/td>\n<td>2<\/td>\n<td>status \u4e0a\u9650\u5148\u5230&#xff0c;\u53ea\u91cd\u8bd5\u4e00\u6b21<\/td>\n<\/tr>\n<tr>\n<td>total&#061;3, connect&#061;1<\/td>\n<td>4<\/td>\n<td>connect \u53ea\u7ba1\u8fde\u63a5\u7c7b\u9519\u8bef&#xff0c;\u7ba1\u4e0d\u5230\u72b6\u6001\u7801<\/td>\n<\/tr>\n<tr>\n<td>total&#061;None, status&#061;3<\/td>\n<td>4<\/td>\n<td>\u6ca1\u6709\u603b\u9884\u7b97&#xff0c;\u7531 status \u8ba1\u6570\u51b3\u5b9a<\/td>\n<\/tr>\n<tr>\n<td>total&#061;3, status_forcelist&#061;[503]<\/td>\n<td>4<\/td>\n<td>\u57fa\u7ebf<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6700\u5bb9\u6613\u8bef\u8bfb\u7684\u662f\u7b2c\u4e8c\u884c&#xff1a;\u4ee5\u4e3a\u5199\u4e86 connect&#061;1 \u5c31\u80fd\u628a\u300c\u603b\u5171\u91cd\u8bd5\u6b21\u6570\u300d\u538b\u5230\u4e00\u6b21&#xff0c;\u5b9e\u9645\u72b6\u6001\u7801\u91cd\u8bd5\u8d70\u7684\u662f\u53e6\u4e00\u672c\u8d26&#xff0c;\u56db\u6b21\u7167\u6253\u3002\u60f3\u9650\u5236\u603b\u91cf&#xff0c;\u8be5\u52a8\u7684\u662f total \u6216 status\u3002<\/p>\n<h3>\u4e94\u3001\u628a raise_on_status \u5173\u6389\u4e3a\u4ec0\u4e48\u66f4\u5371\u9669&#xff1f;<\/h3>\n<p>raise_on_status&#061;False \u5b9e\u6d4b&#xff1a;\u56db\u6b21\u8bf7\u6c42\u7167\u6253&#xff0c;\u4f46\u6700\u540e\u4e0d\u629b\u5f02\u5e38&#xff0c;\u8fd4\u56de\u4e00\u4e2a 503 \u54cd\u5e94&#xff0c;\u5b83\u7684 ok \u662f False\u3002<\/p>\n<p>\u6587\u6863\u5bf9\u5b83\u7684\u5b9a\u4e49\u662f\u91cd\u8bd5\u8017\u5c3d\u4e4b\u540e\u300c\u629b\u5f02\u5e38\u8fd8\u662f\u8fd4\u56de\u54cd\u5e94\u300d\u3002\u770b\u8d77\u6765\u53ea\u662f\u5f02\u5e38\u7b56\u7565\u7684\u533a\u522b&#xff0c;\u5b9e\u9645\u662f\u9759\u9ed8\u9519\u8bef\u6700\u5bb9\u6613\u94bb\u8fdb\u6765\u7684\u5730\u65b9&#xff1a;\u8c03\u7528\u65b9\u5982\u679c\u53ea\u5224\u65ad\u300c\u6709\u6ca1\u6709\u629b\u5f02\u5e38\u300d&#xff0c;\u4f1a\u4ee5\u4e3a\u8fd9\u6b21\u8c03\u7528\u6210\u529f\u4e86&#xff0c;\u63a5\u7740\u53bb\u8bfb resp.json() \u6216 resp.text&#xff0c;\u62ff\u5230\u7684\u5374\u662f\u9519\u8bef\u9875\u3002\u6628\u5929\u90a3\u7bc7\u8bb2\u8fc7\u540c\u65cf\u7684\u300c\u6ca1\u62a5\u9519\u4e0d\u7b49\u4e8e\u6ca1\u6539\u52a8\u7ed3\u679c\u300d&#xff0c;\u8fd9\u91cc\u662f\u540c\u4e00\u4e2a\u5f62\u72b6\u3002<\/p>\n<p>\u4fdd\u7559\u9ed8\u8ba4\u7684 raise_on_status&#061;True&#xff0c;\u5e76\u5728\u62ff\u5230\u54cd\u5e94\u540e\u663e\u5f0f raise_for_status()&#xff0c;\u662f\u6210\u672c\u6700\u4f4e\u7684\u515c\u5e95\u3002\u771f\u8981\u5173\u6389\u5b83&#xff0c;\u5c31\u5fc5\u987b\u628a\u72b6\u6001\u7801\u68c0\u67e5\u5199\u8fdb\u8c03\u7528\u65b9&#xff0c;\u4e0d\u80fd\u7701\u7565\u3002<\/p>\n<h3>\u516d\u3001\u9000\u907f\u4e3a\u4ec0\u4e48\u7b2c\u4e00\u6b21\u4e0d\u7b49\u5f85&#xff1f;<\/h3>\n<p>backoff_factor&#061;0.2 \u65f6&#xff0c;\u6211\u7528 increment \u9010\u6b21\u6784\u9020\u91cd\u8bd5\u5386\u53f2&#xff0c;\u8bfb\u51fa get_backoff_time() \u7684\u5e8f\u5217\u662f [0, 0.4, 0.8, 1.6, 3.2, 6.4]\u3002\u524d\u4e09\u6b21\u91cd\u8bd5\u5206\u522b\u7b49\u5f85 0\u30010.4\u30010.8 \u79d2&#xff0c;\u7d2f\u8ba1 1.2 \u79d2\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261118084852-6afd66749ac52.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u5b98\u65b9\u6587\u6863\u5199\u7684\u662f A backoff factor to apply between attempts after the second try&#xff0c;\u516c\u5f0f\u662f factor \u4e58\u4ee5 2 \u7684\u524d\u6b21\u91cd\u8bd5\u6570\u6b21\u65b9&#xff0c;\u5e76\u7ed9\u4e86 factor&#061;0.1 \u7684\u793a\u4f8b\u5e8f\u5217 [0.0s, 0.2s, 0.4s, 0.8s, &#8230;]\u3002\u672c\u673a\u6e90\u7801\u91cc consecutive_errors_len &lt;&#061; 1 \u76f4\u63a5\u8fd4\u56de 0&#xff0c;\u4e4b\u540e\u624d\u662f factor \u4e58\u4ee5 2 \u7684 n \u51cf 1 \u6b21\u65b9&#xff0c;\u548c\u5b9e\u6d4b\u3001\u548c\u6587\u6863\u793a\u4f8b\u90fd\u5bf9\u5f97\u4e0a\u3002<\/p>\n<p>\u6240\u4ee5\u300c\u4e09\u6b21\u91cd\u8bd5\u4f1a\u7b49 0.2 &#043; 0.4 &#043; 0.8 &#061; 1.4\u300d\u8fd9\u79cd\u4f30\u6cd5\u662f\u9519\u7684&#xff1a;\u7b2c\u4e00\u6b21\u91cd\u8bd5\u6839\u672c\u4e0d\u7b49\u3002\u53e6\u5916\u8fd8\u6709 backoff_max&#061;120 \u5c01\u9876\u3001backoff_jitter&#061;0.0 \u9ed8\u8ba4\u4e0d\u52a0\u6296\u52a8&#xff0c;\u8fd9\u4e24\u4e2a\u503c\u6211\u4e5f\u662f\u76f4\u63a5\u8bfb\u5bf9\u8c61\u786e\u8ba4\u7684&#xff0c;\u4e0d\u662f\u51ed\u5370\u8c61\u3002<\/p>\n<h3>\u4e03\u3001Retry-After \u4f1a\u76d6\u8fc7\u9000\u907f\u516c\u5f0f\u5417&#xff1f;<\/h3>\n<p>\u6709\u4e00\u4e2a\u9ed8\u8ba4\u5f00\u7740\u7684\u5f00\u5173\u503c\u5f97\u77e5\u9053&#xff1a;respect_retry_after_header&#061;True&#xff0c;\u800c RETRY_AFTER_STATUS_CODES \u5b9e\u6d4b\u662f [413, 429, 503]\u3002\u6587\u6863\u8bf4\u5b83\u51b3\u5b9a\u662f\u5426\u5c0a\u91cd\u8fd9\u4e9b\u72b6\u6001\u7801\u4e0a\u7684 Retry-After \u5934\u3002<\/p>\n<p>\u4e5f\u5c31\u662f\u8bf4&#xff0c;\u670d\u52a1\u7aef\u5982\u679c\u56de\u4e86\u4e00\u4e2a\u5e26 Retry-After \u7684 429 \u6216 503&#xff0c;\u7b49\u5f85\u65f6\u95f4\u53ef\u80fd\u4e0d\u8d70\u7b2c\u516d\u8282\u90a3\u6761\u6307\u6570\u66f2\u7ebf\u3002\u8fd9\u4e00\u8282\u6211\u53ea\u6838\u4e86\u9ed8\u8ba4\u5f00\u5173\u3001\u72b6\u6001\u7801\u96c6\u5408\u548c\u6587\u6863\u63aa\u8f9e&#xff0c;\u6ca1\u6709\u5b9e\u6d4b\u771f\u5b9e sleep \u65f6\u957f&#xff08;\u771f\u6309\u5934\u7b49\u4e0b\u53bb\u4f1a\u628a\u63a2\u9488\u62d6\u5f97\u5f88\u6162&#xff09;&#xff0c;\u6240\u4ee5\u8fd9\u91cc\u4e0d\u7ed9\u7b49\u5f85\u79d2\u6570&#xff0c;\u53ea\u63d0\u9192&#xff1a;\u7ebf\u4e0a\u6392\u969c\u770b\u5230\u7b49\u5f85\u65f6\u95f4\u548c\u516c\u5f0f\u5bf9\u4e0d\u4e0a&#xff0c;\u5148\u53bb\u770b\u54cd\u5e94\u5934\u3002<\/p>\n<h3>\u516b\u3001\u8fde\u63a5\u9519\u8bef\u4e0e\u72b6\u6001\u7801\u9519\u8bef\u662f\u4e00\u56de\u4e8b\u5417&#xff1f;<\/h3>\n<p>\u628a\u670d\u52a1\u6539\u6210\u300c\u6536\u5230\u8bf7\u6c42\u5c31\u76f4\u63a5\u5173\u6389\u8fde\u63a5\u300d&#xff0c;\u914d total&#061;2&#xff0c;\u5b9e\u6d4b\u670d\u52a1\u7aef\u88ab\u6253\u4e86\u4e09\u6b21&#xff0c;\u5ba2\u6237\u7aef\u629b ConnectionError\u3002\u6587\u6863\u5bf9 connect \u7684\u89e3\u91ca\u662f\u300c\u8bf7\u6c42\u53d1\u5230\u8fdc\u7aef\u4e4b\u524d\u300d\u7684\u9519\u8bef&#xff0c;\u5bf9 read \u5219\u7279\u522b\u6ce8\u660e\u300c\u8bf7\u6c42\u5df2\u7ecf\u53d1\u51fa&#xff0c;\u53ef\u80fd\u6709\u526f\u4f5c\u7528\u300d\u3002<\/p>\n<p>\u4e24\u8005\u4e0d\u5bf9\u79f0&#xff1a;\u8fde\u63a5\u9519\u8bef\u9ed8\u8ba4\u5c31\u4f1a\u91cd\u8bd5&#xff0c;\u72b6\u6001\u7801\u9519\u8bef\u5fc5\u987b\u663e\u5f0f\u7ed9\u540d\u5355\u3002\u6392\u67e5\u65f6\u5982\u679c\u53ea\u76ef\u7740 5xx&#xff0c;\u5f88\u5bb9\u6613\u6f0f\u6389\u8fde\u63a5\u5c42\u7684\u91cd\u8bd5\u653e\u5927\u3002<\/p>\n<p>\u8fd8\u6709\u4e00\u4e2a\u771f\u5b9e\u8e29\u5230\u7684\u73af\u5883\u5e72\u6270\u503c\u5f97\u8bb0\u4e00\u7b14&#xff1a;\u9996\u7248\u63a2\u9488\u91cc&#xff0c;\u672c\u5730\u56de\u73af\u8bf7\u6c42\u88ab\u673a\u5668\u7684\u4ee3\u7406\u8bbe\u7f6e\u62e6\u4e86\u4e00\u9053&#xff0c;\u629b\u51fa\u6765\u7684\u662f ProxyError \u800c\u4e0d\u662f ConnectionError&#xff0c;\u65ad\u8a00\u5f53\u573a\u7ea2\u4e86\u4e00\u6761\u3002\u7ed9 Session \u8bbe trust_env&#061;False \u4e4b\u540e\u624d\u62ff\u5230\u5e72\u51c0\u7ed3\u679c\u3002\u6d4b\u672c\u5730\u670d\u52a1\u65f6\u5148\u628a\u73af\u5883\u4ee3\u7406\u5173\u6389&#xff0c;\u5426\u5219\u6570\u5230\u7684\u6b21\u6570\u548c\u5f02\u5e38\u7c7b\u578b\u90fd\u4e0d\u5c5e\u4e8e\u4f60\u8981\u6d4b\u7684\u90a3\u5c42\u3002<\/p>\n<h3>\u4e5d\u3001\u4e00\u767e\u4e8c\u5341\u6b21\u8c03\u7528&#xff0c;\u591a\u51fa\u6765\u591a\u5c11\u8bf7\u6c42&#xff1f;<\/h3>\n<p>\u628a\u5355\u6b21\u7ed3\u8bba\u653e\u5230\u89c4\u6a21\u91cc\u770b\u3002\u56fa\u5b9a\u79cd\u5b50\u751f\u6210 120 \u6b21\u8c03\u7528&#xff0c;\u5176\u4e2d 33 \u6b21\u8fd4\u56de 503\u300187 \u6b21\u8fd4\u56de 200&#xff0c;\u6bcf\u6b21\u8c03\u7528\u7684\u8bf7\u6c42\u6b21\u6570\u7531\u672c\u5730\u670d\u52a1\u771f\u5b9e\u8ba1\u6570&#xff1a;<\/p>\n<table>\n<tr>\u53e3\u5f84\u8bf7\u6c42\u6b21\u6570<\/tr>\n<tbody>\n<tr>\n<td>\u6309\u300c\u603b\u5171\u4e09\u6b21\u300d\u4f30\u8ba1<\/td>\n<td>186<\/td>\n<\/tr>\n<tr>\n<td>\u5b9e\u9645\u8ba1\u6570<\/td>\n<td>219<\/td>\n<\/tr>\n<tr>\n<td>\u5dee\u989d<\/td>\n<td>33<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5b9e\u9645\u8fd9\u4e00\u8fb9\u62c6\u5f00\u662f 87 \u6b21\u6210\u529f\u8c03\u7528\u5404 1 \u4e2a\u8bf7\u6c42&#xff0c;\u52a0\u4e0a 33 \u6b21\u5931\u8d25\u8c03\u7528\u5404 4 \u4e2a\u8bf7\u6c42&#xff0c;\u5171 219\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261118084852-6afd6674c2072.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u5dee\u989d\u4e0d\u662f\u4e09\u500d&#xff0c;\u662f\u6bcf\u6b21\u5931\u8d25\u8c03\u7528\u591a\u4e00\u6b21\u3002\u56e0\u4e3a\u76f4\u89c9\u91cc\u7684\u300c\u4e09\u6b21\u300d\u662f\u542b\u539f\u59cb\u8bf7\u6c42\u7684\u603b\u6570&#xff0c;\u5b9e\u9645\u662f 1 \u52a0 3\u3002\u505a\u5bb9\u91cf\u4f30\u7b97\u3001\u7b97\u9650\u6d41\u914d\u989d\u3001\u5bf9\u8d26\u7f51\u5173\u8ba1\u8d39\u65f6&#xff0c;\u7528\u9519\u8fd9\u4e2a\u6570\u4f1a\u7cfb\u7edf\u6027\u4f4e\u4f30\u5931\u8d25\u65f6\u6bb5\u7684\u8bf7\u6c42\u91cf&#xff0c;\u800c\u4e14\u4f4e\u4f30\u7684\u91cf\u6b63\u597d\u7b49\u4e8e\u5931\u8d25\u6b21\u6570\u3002<\/p>\n<h3>\u5341\u3001\u751f\u4ea7\u91cc\u8be5\u600e\u4e48\u914d\u8fd9\u4e2a\u91cd\u8bd5&#xff1f;<\/h3>\n<p>\u628a\u4e0a\u9762\u51e0\u6761\u6536\u6210\u4e00\u4e2a\u53ef\u590d\u7528\u7684\u4f1a\u8bdd\u6784\u9020&#xff1a;<\/p>\n<p><span class=\"token keyword\">import<\/span> requests<br \/>\n<span class=\"token keyword\">from<\/span> requests<span class=\"token punctuation\">.<\/span>adapters <span class=\"token keyword\">import<\/span> HTTPAdapter<br \/>\n<span class=\"token keyword\">from<\/span> urllib3<span class=\"token punctuation\">.<\/span>util<span class=\"token punctuation\">.<\/span>retry <span class=\"token keyword\">import<\/span> Retry<\/p>\n<p><span class=\"token keyword\">def<\/span> <span class=\"token function\">make_session<\/span><span class=\"token punctuation\">(<\/span>total<span class=\"token operator\">&#061;<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">,<\/span> idempotent_only<span class=\"token operator\">&#061;<\/span><span class=\"token boolean\">True<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    retry <span class=\"token operator\">&#061;<\/span> Retry<span class=\"token punctuation\">(<\/span><br \/>\n        total<span class=\"token operator\">&#061;<\/span>total<span class=\"token punctuation\">,<\/span><br \/>\n        status_forcelist<span class=\"token operator\">&#061;<\/span><span class=\"token punctuation\">[<\/span><span class=\"token number\">429<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">500<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">502<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">503<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">504<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span><br \/>\n        allowed_methods<span class=\"token operator\">&#061;<\/span><span class=\"token punctuation\">(<\/span><br \/>\n            Retry<span class=\"token punctuation\">.<\/span>DEFAULT_ALLOWED_METHODS <span class=\"token keyword\">if<\/span> idempotent_only <span class=\"token keyword\">else<\/span> <span class=\"token boolean\">None<\/span><br \/>\n        <span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n        backoff_factor<span class=\"token operator\">&#061;<\/span><span class=\"token number\">0.2<\/span><span class=\"token punctuation\">,<\/span><br \/>\n        raise_on_status<span class=\"token operator\">&#061;<\/span><span class=\"token boolean\">True<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token punctuation\">)<\/span><br \/>\n    s <span class=\"token operator\">&#061;<\/span> requests<span class=\"token punctuation\">.<\/span>Session<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    s<span class=\"token punctuation\">.<\/span>mount<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;https:\/\/&#034;<\/span><span class=\"token punctuation\">,<\/span> HTTPAdapter<span class=\"token punctuation\">(<\/span>max_retries<span class=\"token operator\">&#061;<\/span>retry<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> s<\/p>\n<p>resp <span class=\"token operator\">&#061;<\/span> make_session<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span>url<span class=\"token punctuation\">,<\/span> timeout<span class=\"token operator\">&#061;<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span><br \/>\nresp<span class=\"token punctuation\">.<\/span>raise_for_status<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>\u4e94\u6761\u7ea6\u5b9a&#xff1a;<\/p>\n<li>\u663e\u5f0f\u7ed9 status_forcelist&#xff0c;\u522b\u6307\u671b\u9ed8\u8ba4\u503c\u4f1a\u66ff\u4f60\u91cd\u8bd5 5xx\u3002<\/li>\n<li>\u5199\u5165\u7c7b\u63a5\u53e3\u4e0d\u8981\u968f\u624b\u653e\u5f00 allowed_methods&#xff0c;\u5148\u786e\u8ba4\u5e42\u7b49\u952e&#xff1b;\u53ea\u91cd\u8bd5\u8fde\u63a5\u9519\u8bef\u662f\u66f4\u4fdd\u5b88\u7684\u9009\u62e9\u3002<\/li>\n<li>\u4fdd\u7559 raise_on_status&#061;True&#xff0c;\u62ff\u5230\u54cd\u5e94\u540e\u7167\u6837 raise_for_status()\u3002<\/li>\n<li>\u8bbe backoff_factor \u5e76\u7559\u610f backoff_max \u4e0a\u9650&#xff0c;\u907f\u514d\u5931\u8d25\u65f6\u6bb5\u628a\u7b49\u5f85\u62c9\u5f97\u8fc7\u957f\u3002<\/li>\n<li>\u5355\u6b21\u8bf7\u6c42\u7684 timeout \u4e0e\u91cd\u8bd5\u662f\u4e24\u5c42&#xff1a;\u8d85\u65f6\u7ba1\u6bcf\u4e00\u6b21\u5c1d\u8bd5&#xff0c;\u91cd\u8bd5\u7ba1\u5c1d\u8bd5\u51e0\u6b21&#xff0c;\u522b\u7528\u4e00\u4e2a\u53bb\u66ff\u4ee3\u53e6\u4e00\u4e2a\u3002<\/li>\n<p>\u6700\u540e\u4e00\u6761\u662f\u5de5\u7a0b\u63d0\u9192&#xff0c;\u672c\u8f6e\u6ca1\u6709\u6d4b\u8d85\u65f6\u4e0e\u91cd\u8bd5\u7684\u4ea4\u4e92&#xff0c;\u4e0d\u5199\u5177\u4f53\u65f6\u957f\u3002<\/p>\n<h3>\u5341\u4e00\u3001\u600e\u4e48\u5728\u65e5\u5fd7\u91cc\u770b\u89c1\u91cd\u8bd5\u6b21\u6570&#xff1f;<\/h3>\n<p>\u4e09\u6761\u80fd\u843d\u5730\u7684\u529e\u6cd5&#xff1a;<\/p>\n<p><span class=\"token keyword\">import<\/span> logging<\/p>\n<p><span class=\"token comment\"># 1. \u6253\u5f00 urllib3 \u7684\u91cd\u8bd5\u65e5\u5fd7<\/span><br \/>\nlogging<span class=\"token punctuation\">.<\/span>basicConfig<span class=\"token punctuation\">(<\/span>level<span class=\"token operator\">&#061;<\/span>logging<span class=\"token punctuation\">.<\/span>INFO<span class=\"token punctuation\">)<\/span><br \/>\nlogging<span class=\"token punctuation\">.<\/span>getLogger<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;urllib3.util.retry&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>setLevel<span class=\"token punctuation\">(<\/span>logging<span class=\"token punctuation\">.<\/span>DEBUG<span class=\"token punctuation\">)<\/span><\/p>\n<li>\u5ba2\u6237\u7aef\u4e34\u65f6\u628a urllib3.util.retry \u7684\u65e5\u5fd7\u7ea7\u522b\u8c03\u5230 DEBUG&#xff0c;\u80fd\u76f4\u63a5\u770b\u5230\u6bcf\u6b21\u9000\u907f\u4e0e\u91cd\u8bd5\u51b3\u7b56\u3002<\/li>\n<li>\u670d\u52a1\u7aef\u6216\u7f51\u5173\u4fa7\u6309\u540c\u4e00\u4e2a\u8bf7\u6c42\u6807\u8bc6\u7edf\u8ba1\u547d\u4e2d\u6b21\u6570&#xff0c;\u8fd9\u662f\u552f\u4e00\u80fd\u8bc1\u660e\u300c\u5230\u5e95\u6253\u4e86\u51e0\u4e0b\u300d\u7684\u4e00\u4fa7\u3002<\/li>\n<li>\u5728 HTTPAdapter \u5916\u5305\u4e00\u5c42\u8ba1\u6570&#xff0c;\u628a\u6bcf\u6b21 send \u4e0e\u6700\u7ec8\u72b6\u6001\u7801\u4e00\u8d77\u8bb0\u4e0b\u6765&#xff1b;\u6709\u4e86\u8fd9\u4e24\u4e2a\u6570&#xff0c;\u7b2c\u4e5d\u8282\u90a3 33 \u6b21\u5dee\u989d\u5728\u53d1\u751f\u65f6\u5c31\u80fd\u770b\u89c1\u3002<\/li>\n<p>\u5173\u952e\u662f\u522b\u9760\u914d\u7f6e\u53cd\u63a8\u6d41\u91cf\u3002\u8bbe\u4e86 total&#061;3 \u53ea\u80fd\u8bf4\u660e\u4f60\u5141\u8bb8\u4e86\u4e09\u6b21\u91cd\u8bd5&#xff0c;\u4e0d\u80fd\u8bf4\u660e\u5b9e\u9645\u53d1\u4e86\u51e0\u6b21\u8bf7\u6c42&#xff1b;\u524d\u8005\u662f\u610f\u56fe&#xff0c;\u540e\u8005\u8981\u7528\u8ba1\u6570\u8bf4\u8bdd\u3002<\/p>\n<h3>\u6536\u53e3<\/h3>\n<p>\u6570\u636e\u5c42&#xff1a;<\/p>\n<li>Retry(total&#061;3, status_forcelist&#061;[503]) \u5b9e\u6d4b\u6253 4 \u6b21\u8bf7\u6c42\u5e76\u629b RetryError&#xff1b;total&#061;0 \u6253 1 \u6b21\u4f46\u4ecd\u629b RetryError&#xff1b;\u54cd\u5e94\u4e3a 200 \u65f6\u53ea\u6253 1 \u6b21\u3002<\/li>\n<li>\u4e0d\u914d status_forcelist \u65f6\u53ea\u6253 1 \u6b21\u3001\u76f4\u63a5\u8fd4\u56de 503&#xff0c;\u7b49\u4e8e\u6ca1\u6709\u91cd\u8bd5&#xff1b;raise_on_status&#061;False \u6253 4 \u6b21\u540e\u8fd4\u56de 503 \u4e14\u4e0d\u629b\u5f02\u5e38\u3002<\/li>\n<li>\u9ed8\u8ba4\u65b9\u6cd5\u96c6\u4e3a DELETE&#xff0f;GET&#xff0f;HEAD&#xff0f;OPTIONS&#xff0f;PUT&#xff0f;TRACE&#xff0c;\u4e0d\u542b POST&#xff1b;POST \u9ed8\u8ba4 1 \u6b21&#xff0c;allowed_methods&#061;None \u540e 4 \u6b21\u3002<\/li>\n<li>status&#061;1 \u6253 2 \u6b21&#xff0c;connect&#061;1 \u4ecd\u6253 4 \u6b21&#xff0c;total&#061;None, status&#061;3 \u6253 4 \u6b21&#xff1b;backoff_factor&#061;0.2 \u7684\u9000\u907f\u5e8f\u5217\u4e3a [0, 0.4, 0.8, 1.6, 3.2, 6.4]&#xff0c;\u524d\u4e09\u6b21\u7d2f\u8ba1 1.2 \u79d2\u3002<\/li>\n<li>120 \u6b21\u8c03\u7528&#xff08;33 \u6b21\u8fd4\u56de 503&#xff09;\u5b9e\u9645 219 \u6b21\u8bf7\u6c42&#xff0c;\u6309\u300c\u603b\u5171\u4e09\u6b21\u300d\u4f30\u8ba1\u662f 186 \u6b21&#xff0c;\u5dee\u989d 33 \u6b21\u6070\u7b49\u4e8e\u5931\u8d25\u8c03\u7528\u6570&#xff1b;\u8fde\u63a5\u88ab\u76f4\u63a5\u5173\u95ed\u65f6 total&#061;2 \u6253 3 \u6b21\u5e76\u629b ConnectionError\u3002<\/li>\n<p>\u5de5\u7a0b\u5c42&#xff1a;<\/p>\n<li>\u628a total \u7406\u89e3\u4e3a\u91cd\u8bd5\u6b21\u6570\u800c\u975e\u8bf7\u6c42\u6b21\u6570&#xff0c;\u5bb9\u91cf\u4e0e\u9650\u6d41\u4f30\u7b97\u6309 1 \u52a0 N \u8ba1\u7b97\u3002<\/li>\n<li>\u663e\u5f0f\u7ed9 status_forcelist&#xff1b;\u5199\u5165\u7c7b\u63a5\u53e3\u4fdd\u6301\u9ed8\u8ba4\u65b9\u6cd5\u96c6&#xff0c;\u9700\u8981\u91cd\u8bd5\u65f6\u5148\u89e3\u51b3\u5e42\u7b49\u6027\u3002<\/li>\n<li>\u4fdd\u7559 raise_on_status&#061;True \u5e76\u914d\u5408 raise_for_status()&#xff0c;\u4e0d\u8981\u53ea\u51ed\u300c\u6ca1\u629b\u5f02\u5e38\u300d\u5224\u65ad\u6210\u529f\u3002<\/li>\n<li>\u8bbe backoff_factor \u5e76\u7559\u610f backoff_max \u4e0e Retry-After&#xff1b;\u7528 DEBUG \u65e5\u5fd7\u548c\u670d\u52a1\u7aef\u8ba1\u6570\u9a8c\u8bc1\u5b9e\u9645\u8bf7\u6c42\u6570&#xff0c;\u522b\u9760\u914d\u7f6e\u53cd\u63a8\u3002<\/li>\n<hr \/>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261118084852-6afd6674e7404.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>      <span id=\"quality-guide-article-end\" aria-hidden=\"true\" style=\"display:block;height:1px;margin-bottom:-1px\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content<\/p>\n","protected":false},"author":2,"featured_media":124158,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[9098,9147,14231,14230,14232,81],"topic":[],"class_list":["post-124162","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-it","tag-requests","tag-retry","tag-urllib3","tag-14232","tag-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u8bf4\u597d\u91cd\u8bd5\u4e09\u6b21\uff0c\u670d\u52a1\u5668\u6536\u5230\u56db\u4e0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/124162.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u8bf4\u597d\u91cd\u8bd5\u4e09\u6b21\uff0c\u670d\u52a1\u5668\u6536\u5230\u56db\u4e0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/124162.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-18T08:48:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261118084852-6afd667471f6e.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/124162.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/124162.html\",\"name\":\"\u8bf4\u597d\u91cd\u8bd5\u4e09\u6b21\uff0c\u670d\u52a1\u5668\u6536\u5230\u56db\u4e0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-11-18T08:48:55+00:00\",\"dateModified\":\"2026-11-18T08:48:55+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/124162.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/124162.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/124162.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u8bf4\u597d\u91cd\u8bd5\u4e09\u6b21\uff0c\u670d\u52a1\u5668\u6536\u5230\u56db\u4e0b\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u8bf4\u597d\u91cd\u8bd5\u4e09\u6b21\uff0c\u670d\u52a1\u5668\u6536\u5230\u56db\u4e0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/124162.html","og_locale":"zh_CN","og_type":"article","og_title":"\u8bf4\u597d\u91cd\u8bd5\u4e09\u6b21\uff0c\u670d\u52a1\u5668\u6536\u5230\u56db\u4e0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content","og_url":"https:\/\/www.wsisp.com\/helps\/124162.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-11-18T08:48:55+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261118084852-6afd667471f6e.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/124162.html","url":"https:\/\/www.wsisp.com\/helps\/124162.html","name":"\u8bf4\u597d\u91cd\u8bd5\u4e09\u6b21\uff0c\u670d\u52a1\u5668\u6536\u5230\u56db\u4e0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-11-18T08:48:55+00:00","dateModified":"2026-11-18T08:48:55+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/124162.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/124162.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/124162.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u8bf4\u597d\u91cd\u8bd5\u4e09\u6b21\uff0c\u670d\u52a1\u5668\u6536\u5230\u56db\u4e0b"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/124162","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=124162"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/124162\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/124158"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=124162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=124162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=124162"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=124162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}