Python2 HTTPAdapter: How to Handle Persistent Connections and Timeouts Effectively?

18 Replies, 1668 Views

Persistent connections in Python2 HTTPAdapter are a mess, no question. One thing that helped me was setting `pool_connections` to a lower number and using `pool_maxsize` to limit the pool.

For timeouts, I’ve found that setting `connect_timeout` and `read_timeout` separately helps. Sometimes the library just doesn’t respect the global timeout, so breaking it down can make a difference.

Also, have you tried using `socket.setdefaulttimeout()`? It’s a bit of a hack, but it can help enforce timeouts at a lower level.

Messages In This Thread



Users browsing this thread: 1 Guest(s)