1

My program wants to get the webpage contents on a private IP(10.0.0.0/8) in internal network. I am using python requests.get() for that purpose.


I went through question Why doesn't requests.get() return? What is the default timeout that requests.get() uses? but I did not get much help

  1. On what basis is the default timeout for python get request determined ?
  2. Is it dependent on the TCP stack configuration ? Which file hosts that configuration ?
Community
  • 1
  • 1
Neeraj Dixit
  • 61
  • 1
  • 4
  • 1
    You don't give a lot of information about *which machines / platforms* you are testing this on. My guess is that the timeout is being managed by the OS, not the library. 45 seconds (or some multiple thereof) used to be common, but that was a while ago. – Peter Rowell Aug 16 '16 at 01:38
  • I am using a Centos distribution running a 2.6 kernel version – Neeraj Dixit Aug 16 '16 at 06:42

1 Answers1

-2
  1. Again, the default timeout is None, you can dig into the library files in your OS (the path is /usr/local/lib/python2.7/site-packages/requests/ in my Mac OSX)

    • two files to look into is api.py and sessions.py
    • for timeout part, line 275 file sessions.py
  2. You can read the document here: http://docs.python-requests.org/en/master/user/quickstart/#timeouts (the Note part)

Joe
  • 15
  • 2
  • Thanks Joe for the answer but that part does not explain why the time out is different for different machines ... I suspect it has something to do with OS TCP stack configuration but I am not able to find any documentation – Neeraj Dixit Aug 16 '16 at 06:43
  • Welcome to SO. This would be better suited as a comment, I know you need to get a certain level of cred to comment, but hopefully this can help you with improving your answer. http://stackoverflow.com/help/how-to-answer – Tom Myddeltyn Aug 16 '16 at 13:17