diff --git a/python_apps/airtime_analyzer/airtime_analyzer/cloud_storage_uploader.py b/python_apps/airtime_analyzer/airtime_analyzer/cloud_storage_uploader.py index 9337344b8..f1999c9e4 100644 --- a/python_apps/airtime_analyzer/airtime_analyzer/cloud_storage_uploader.py +++ b/python_apps/airtime_analyzer/airtime_analyzer/cloud_storage_uploader.py @@ -1,10 +1,12 @@ import os import logging import uuid +import socket from boto.s3.connection import S3Connection from boto.s3.key import Key STORAGE_BACKEND_FILE = "file" +SOCKET_TIMEOUT = 240 class CloudStorageUploader: """ A class that uses Python-Boto SDK to upload objects into Amazon S3. @@ -88,6 +90,10 @@ class CloudStorageUploader: resource_id = "%s/%s/%s_%s%s" % (metadata['file_prefix'], unique_id_prefix, file_name, unique_id, extension) + # Boto uses the "global default timeout" by default, which is infinite! To prevent network problems from + # turning into deadlocks, we explicitly set the global default timeout period here: + socket.setdefaulttimeout(SOCKET_TIMEOUT) + conn = S3Connection(self._api_key, self._api_key_secret, host=self._host) bucket = conn.get_bucket(self._bucket)