Skip to content

Commit 79ff175

Browse files
committed
add comment
1 parent 7f725a7 commit 79ff175

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

swanlab/core_python/client/session.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818
DEFAULT_TIMEOUT = 60
1919

2020

21-
# 创建一个自定义的 HTTPAdapter,用于注入默认超时
2221
class TimeoutHTTPAdapter(HTTPAdapter):
22+
"""
23+
创建一个自定义的 HTTPAdapter,用于注入默认超时
24+
并可以通过请求 headers 中的 {RETRY_HEADER} 指定并临时修改重试次数
25+
"""
26+
2327
def __init__(self, *args, **kwargs):
2428
# 从 kwargs 中取出默认超时时间,如果没有则设为 None
2529
self.timeout = kwargs.pop("timeout", None)
@@ -42,6 +46,11 @@ def send(self, request, **kwargs):
4246

4347

4448
class SwanSession(requests.Session):
49+
"""
50+
自定义会话,用于自定义会话重试次数
51+
可以接受一个 retries 参数,并将其放在 headers 中的 {RETRY_HEADER} 字段中
52+
"""
53+
4554
def request(self, method, url, *args, **kwargs):
4655
retries = kwargs.pop('retries', None)
4756

0 commit comments

Comments
 (0)