Periodic ReadTimeoutError while tryint to Upload
Hello,
I have written a little app that generates images from Matplotlib in Python and then uploads it via Cloudinary. I get errors such like:
Failed to upload image: Unexpected error - ReadTimeoutError("HTTPSConnectionPool(host='api.cloudinary.com', port=443): Read timed out. (read timeout=<object object at 0x7f30797ee240>)",)
Weirdly enough, when one upload fails, the next works again. I have a feeling that the error occurs after a period where no image was uploaded for a couple of minutes. Any ideas are welcome! The function that does the uploading looks like this:
def upload_image(image, hash):
"""Takes a path to an image an uploads it. Return the Image URL"""
cloudinary.config(cloud_name=cloudinary_conf['cloud_name'],
api_key=cloudinary_conf['api_key'],
api_secret=cloudinary_conf['api_secret'])
try:
result = cloudinary.uploader.upload(image, public_id = hash)
URL = cloudinary.utils.cloudinary_url(result['public_id'])[0]
logger.debug("Uploaded image: %s", URL)
except cloudinary.api.Error as e:
logger.warn("Failed to upload image: %s", e)
URL = "http://res.cloudinary.com/destats/image/upload/" + hash
return(URL)
Please sign in to leave a comment.
Comments
1 comment