Referring to the following code in python 3 to download an image from url-
import urllib.request
try:
print('entering urlretrieve')
# If connection failed after entering the function urllib.request.urlretrieve()
urllib.request.urlretrieve('img_url','temp_location')
print('exited urlretrieve')
except:
print('connection problem')
print('program ended')
Now, problem is if connection fails inside urllib.request.urlretrieve() then the program simply waits and do nothing
Output in this case is -
entering urlretrieve.
But, my requirement is to terminate printing -
connection problem
when exception occur inside this function.
Please Help!