Skip to content

Instantly share code, notes, and snippets.

View lv123123long's full-sized avatar

beautifulfox lv123123long

View GitHub Profile
@laixintao
laixintao / decent_request.py
Last active January 18, 2025 08:12
Send HTTP requests using python-requests with timeout, tcp reuse(session) and retry.
from requests.adapters import HTTPAdapter, Retry
from requests import Session
retries = Retry(
total=5, backoff_factor=1, status_forcelist=[502, 503, 504]
)
session = Session() # reuse tcp connection
session.mount("http://", HTTPAdapter(max_retries=retries))
session.mount("https://", HTTPAdapter(max_retries=retries))
@baymaxium
baymaxium / content.md
Created October 18, 2017 09:08
深入理解 Python 异步编程(上)

原文:Python开发者

(点击上方蓝字,快速关注我们)

来源:阿驹的自荐投稿(微信公号:驹说码事) 

如有好文章投稿,请点击 → 这里了解详情

前言