Sajid Sajid - 4 months ago 11
HTTP Question

What is the Python equivalent of RequestConfig in Java?

I have the following piece of code in Java:

RequestConfig.custom().setSocketTimeout(10).setConnectTimeout(20).build();


How do I achieve the same thing in Python?

Answer

Please, take a look to this answer where is shown how to set timeout.

It results from documentation that setSocketTimeout and setConnectTimeout are the same things in Python.

Note that the connect() operation is subject to the timeout setting, and in general it is recommended to call settimeout() before calling connect() or pass a timeout parameter to create_connection(). The system network stack may return a connection timeout error of its own regardless of any Python socket timeout setting.

Comments