Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python 开发笔记 #36

Open
imfenghuang opened this issue Sep 25, 2022 · 0 comments
Open

python 开发笔记 #36

imfenghuang opened this issue Sep 25, 2022 · 0 comments

Comments

@imfenghuang
Copy link
Owner

requests 请求重试,连接池设定

import requests
from requests.adapters import HTTPAdapter

R = requests.Session()
R.mount( "http://", HTTPAdapter(max_retries=1000, pool_connections=1000, pool_maxsize=2000))
R.mount( "https://", HTTPAdapter(max_retries=1000, pool_connections=1000, pool_maxsize=2000))

 R.get(url, timeout=(10, 30))

多线程

from threading import Thread

threadList = []
for item in arr:
    t = Thread(
        target=fn,
        args=(args),
    )
    threadList.append(t)
    t.start()

for t in threadList:
    t.join()

Github Actions 日志输出

import logging

logging.warning("string")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant