2

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?

  • http://stackoverflow.com/a/3432222/3014866 – Rudziankoŭ Aug 01 '16 at 07:41
  • 1
    I have actually looked at that question before. The problem is there is a `settimeout()` function which sets the timeout for socket operations, but I can't seem to find a timeout option for the connection operations. –  Aug 01 '16 at 07:48

1 Answers1

0

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.

Community
  • 1
  • 1
Rudziankoŭ
  • 10,681
  • 20
  • 92
  • 192