Skip to content

Commit

Permalink
Merge branch 'feature/retry' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
borislavd88 committed Oct 19, 2020
2 parents 3e0a6c5 + 91f0f35 commit 4960e31
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sevenbridges/http/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from datetime import datetime as dt

import requests
from requests.packages.urllib3.util import Retry as UrlLibRetry

import sevenbridges
from sevenbridges.decorators import check_for_error, throttle
Expand Down Expand Up @@ -62,10 +63,16 @@ def generate_session(pool_connections, pool_maxsize, pool_block, proxies=None):
:return: requests.Session object.
"""
session = RequestSession()

# Retry if no response from server (failed DNS lookups, socket connections
# and connection timeouts.
retries = UrlLibRetry(total=6, backoff_factor=1)

adapter = requests.adapters.HTTPAdapter(
pool_connections=pool_connections,
pool_maxsize=pool_maxsize,
pool_block=pool_block
pool_block=pool_block,
max_retries=retries
)
session.mount('http://', adapter)
session.mount('https://', adapter)
Expand Down

0 comments on commit 4960e31

Please sign in to comment.