diff --git a/shotgun_api3/shotgun.py b/shotgun_api3/shotgun.py index 3f259fd2..e44e088d 100644 --- a/shotgun_api3/shotgun.py +++ b/shotgun_api3/shotgun.py @@ -3976,8 +3976,15 @@ def _upload_data_to_storage(self, data, content_type, size, storage_url): request.add_header("Content-Type", content_type) request.add_header("Content-Length", size) request.get_method = lambda: "PUT" - result = opener.open(request) + if self.config.timeout_secs is not None: + result = opener.open(request, timeout=self.config.timeout_secs) + else: + result = opener.open(request) etag = result.info()["Etag"] + + except ssl.SSLError, e: + raise ShotgunError("Unanticipated error occurred uploading to %s: %s" % (storage_url, e)) + except urllib.error.HTTPError as e: if e.code == 500: raise ShotgunError("Server encountered an internal error.\n%s\n%s\n\n" % (storage_url, e)) @@ -4069,9 +4076,16 @@ def _send_form(self, url, params): # Perform the request try: - resp = opener.open(url, params) + if self.config.timeout_secs is not None: + resp = opener.open(url, params, timeout=self.config.timeout_secs) + else: + resp = opener.open(url, params) result = resp.read() # response headers are in str(resp.info()).splitlines() + + except ssl.SSLError, e: + raise ShotgunError("Unanticipated error occurred %s" % (e)) + except urllib.error.HTTPError as e: if e.code == 500: raise ShotgunError("Server encountered an internal error. "