IBP: Fix socket.timeout catching

Recent version of python-requests doesn't catch socket.timeout()
This patch resolves the issue by explicit adding socket.timeout to
the list of expected exceptions to be caught.

Change-Id: Ifcadf9efbec633175bb1bd31cf7f58732c2e78c4
Closes-Bug: #1458526
This commit is contained in:
Alexander Gordeev 2015-05-25 20:46:08 +03:00
parent 8af039fec4
commit 8693edb138
2 changed files with 5 additions and 1 deletions

View File

@ -18,6 +18,7 @@ import testtools
import mock
from oslo.config import cfg
import requests
import socket
import stevedore
import urllib3
@ -140,6 +141,7 @@ class ExecuteTestCase(testtools.TestCase):
requests.exceptions.ConnectionError(),
requests.exceptions.Timeout(),
requests.exceptions.TooManyRedirects(),
socket.timeout(),
mock_ok]
req_obj = utils.init_http_request('fake_url')
self.assertEqual(mock_ok, req_obj)

View File

@ -18,6 +18,7 @@ import math
import os
import re
import shlex
import socket
import subprocess
import time
@ -203,7 +204,8 @@ def init_http_request(url, byte_range=0):
url, stream=True,
timeout=CONF.http_request_timeout,
headers={'Range': 'bytes=%s-' % byte_range})
except (urllib3.exceptions.DecodeError,
except (socket.timeout,
urllib3.exceptions.DecodeError,
urllib3.exceptions.ProxyError,
requests.exceptions.ConnectionError,
requests.exceptions.Timeout,