Can I change the connection pool size for Python's “requests” module?

后端 未结 2 923
忘掉有多难
忘掉有多难 2020-12-02 13:16

(edit: Perhaps I am wrong in what this error means. Is this indicating that the connection pool at my CLIENT is full? or a connection pool at the SERVER is full and this

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 13:47

    This should do the trick:

    import requests
    sess = requests.Session()
    adapter = requests.adapters.HTTPAdapter(pool_connections=100, pool_maxsize=100)
    sess.mount('http://', adapter)
    resp = sess.get("/mypage")
    

提交回复
热议问题