I'm using following code, to get a big API response using python requests library :
try :
r = requests.get("download_link")
data = r.content
except requests.exceptions.ConnectionError as ex:
print('Issue file download...'+str(ex))
except Exception as ex:
print('Issue file download...'+str(ex))
Python requests version : 2.18.4,
Python version : 3-x
Here the use case is, as soon as the API is called, I'm disconnecting the internet, and this is not throwing any error(program is stuck at the API call). The API called would take 30+ secs to give complete response based on network speed, and there is high possibility of internet disconnection during this API call.
I would like to catch error when internet disconnects during the API call. Could someone please guide me on how to handle it.