Skip to content

Commit

Permalink
Add retry handler to default session. (#13)
Browse files Browse the repository at this point in the history
This adds a simple retry handler to the default session in the
CartAPI constructor.

Signed-off-by: David Brown <dmlb2000@gmail.com>
  • Loading branch information
dmlb2000 committed Feb 17, 2019
1 parent 3c38e03 commit 38fc739
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ install:
redis-64\tools\redis-server.exe --service-start;
python -m pip install -r requirements-dev.txt;
python -m pip install 'redis<3.0';
echo 'Done';
build: off

Expand Down
6 changes: 5 additions & 1 deletion pacifica/downloader/cartapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ def __init__(self, cart_api_url, **kwargs):
dictionary can be passed via keyword arguments.
"""
self.cart_api_url = cart_api_url
self.session = kwargs.get('session', requests.Session())
adapter = requests.adapters.HTTPAdapter(max_retries=5)
session = requests.Session()
session.mount('http://', adapter)
session.mount('https://', adapter)
self.session = kwargs.get('session', session)
self.auth = kwargs.get('auth', {})

def setup_cart(self, yield_files):
Expand Down

0 comments on commit 38fc739

Please sign in to comment.