Skip to content

Commit

Permalink
Merge pull request #10 from haizaar/master
Browse files Browse the repository at this point in the history
Catching timeouts
  • Loading branch information
haizaar committed Aug 6, 2015
2 parents 7172977 + f16970b commit f660033
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions krest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from __future__ import absolute_import

__version__ = "1.2.3"
__version__ = "1.2.4"

import json
import urlparse
Expand All @@ -18,7 +18,7 @@
import traceback

import requests
from requests.exceptions import ConnectionError, HTTPError
from requests.exceptions import ConnectionError, HTTPError, Timeout
import time


Expand Down Expand Up @@ -90,8 +90,8 @@ def wrapped(self, *args, **kwargs):
retry = False
try:
return func(self, *args, **kwargs)
except ConnectionError, err:
logger.error("Connection Error: %s", str(err))
except (ConnectionError, Timeout) as err:
logger.error("Connection/Timeout Error: %s", str(err))
if self.retry_cfg.on_connect_errors:
retry = True
except HTTPError, err:
Expand Down Expand Up @@ -553,4 +553,4 @@ def __iter__(self):
yield item

def __len__(self):
return len(self._items)
return len(self._items)
2 changes: 1 addition & 1 deletion krest.spec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%global pypi_name krest

Name: python-%{pypi_name}
Version: 1.2.3
Version: 1.2.4
Release: 1%{?dist}
Summary: Python client for Kaminario K2 REST interface

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"""

setup(name="krest",
version="1.2.3",
version="1.2.4",
py_modules=["krest"],
install_requires=["requests >= 2.0.0"],
maintainer="Zaar Hai",
Expand Down
4 changes: 2 additions & 2 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,15 @@ def _test_list(self, rest_objects=True):
vols_single = []

if rest_objects:
vgs = self.ep.search("volume_groups")
vgs = self.ep.search("volume_groups", __limit=2)
for vg in vgs:
vols_single.extend(self.ep.search("volumes", volume_group=vg).hits)
vols_multi = self.ep.search("volumes", volume_group=vgs).hits
else:
vols = self.ep.search("volumes", __limit=2)
for v in vols:
vols_single.extend(self.ep.search("volumes", name=v.name).hits)
vols_multi = self.ep.search("volumes", name=[vg.name for vg in vols]).hits
vols_multi = self.ep.search("volumes", name=[v.name for v in vols]).hits

self.assertEqual(len(vols_multi), len(vols_single),
msg="Single and multi queries returned different amount of results")
Expand Down

0 comments on commit f660033

Please sign in to comment.