Does the timeout value for Python requests refer to first byte received or whole message? -


the documentation (http://docs.python-requests.org/en/latest/api/#requests.request) explains timeout value this:

timeout (float or tuple) -- (optional) how long wait server send data before giving up, float, or (connect timeout, read timeout) tuple.

response = requests.post(url, data=post_fields, timeout=timeout) 

does mean wait server send single byte, or wait server send "whole" message? in other words, single timeout value (not tuple), timeout read() call?

if specify timeout float (not tuple), equivalent specify tuple components same value:

import requests  try:     response = requests.post('http://httpbin.org/post', timeout=0.1) except requests.exceptions.timeout e:     print(e) 

if setting timeout extremely small (0.001) connecttimeouterror:

httpconnectionpool(host='httpbin.org', port=80): max retries exceeded url: /post (caused connecttimeouterror(<requests.packages.urllib3.connection.httpconnection object @ 0x039970d0>, 'connection httpbin.org timed out. (connect timeout=0.001)')) 

increasing value (0.1) results in successful connection establishment, read() times out:

httpconnectionpool(host='httpbin.org', port=80): read timed out. (read timeout=0.1) 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -