Permalink
Browse files

add exponential backoff

  • Loading branch information...
rdhyee committed May 21, 2017
1 parent 77f727a commit 60b1227fb2263019a3ec74ae9d0254f965cd5e46
Showing with 8 additions and 1 deletion.
  1. +8 −1 Hypothes_is/__init__.py
@@ -1,6 +1,7 @@
import json
import re
import requests
from requests.packages.urllib3.util.retry import Retry
from requests.adapters import HTTPAdapter
import time
import traceback
@@ -34,8 +35,14 @@ def __init__(self, username=None, token=None, group=None, limit=None, max_result
"admin": ['acct:' + self.username + '@hypothes.is']
}
else: self.permissions = {}

# http://stackoverflow.com/a/35504626
self.session = requests.Session()
self.session.mount(self.api_url, HTTPAdapter(max_retries=3))
retries = Retry(total=5,
backoff_factor=0.1,
status_forcelist=[ 500, 502, 503, 504 ])

self.session.mount(self.api_url, HTTPAdapter(max_retries=retries))


def search(self, params={}):

0 comments on commit 60b1227

Please sign in to comment.