0

My backend runs on openshift and makes get requests to other openshift clusters via kubernetes python client. I am having an issue where requests hang until the default timeout value is reached. I have done some tests in the pod to see if it can reach other openshift clusters and discovered the following: requests.get("some_other_cluster_api_url") will hang and return correctly in 2 mins, but requests.get("some_other_cluster_api_url", timeout=1) returns correctly in 1 second. Why does the request not return immediately in the first case?

Edit: curl also instantly returns the right response

1 Answers1

0

As per this Timeout Doc, in the first case you have not set any timeout value By default, requests do not time out unless a timeout value is set explicitly. Without a timeout, your code may hang for minutes or more.

In the second case, you have set the timeout value to 1 , which returns the response in 1 second only.

For example :

If you specify a single value for the timeout, like this:
r = requests.get('https://github.com', timeout=5)

Then it returns the response in 5 seconds .

Refer to this Doc and SO for more information and usage of timeout requests.

Hemanth Kumar
  • 2,728
  • 1
  • 4
  • 19