Skip to content

Commit

Permalink
New retrying library (tenacity)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnsilva committed Nov 1, 2019
1 parent d8aa471 commit 69e53c9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Expand Up @@ -9,8 +9,8 @@ Pygments==2.4.2
readme-renderer==24.0
requests==2.22.0
requests-toolbelt==0.9.1
retrying==1.3.3
six==1.12.0
tenacity==5.1.5
tqdm==4.32.2
twine==1.13.0
urllib3==1.25.3
Expand Down
9 changes: 4 additions & 5 deletions semanticscholar/restful.py
@@ -1,5 +1,5 @@
import requests
from retrying import retry
from tenacity import *

API_URL = 'http://api.semanticscholar.org/v1'

Expand Down Expand Up @@ -31,10 +31,9 @@ def author(id) -> dict:
return data

@retry(
retry_on_exception=lambda x: isinstance(x, ConnectionRefusedError),
stop_max_attempt_number=12,
wait_random_min=1000,
wait_random_max=5000
wait=wait_fixed(30),
retry=retry_if_exception_type(ConnectionRefusedError),
stop=stop_after_attempt(10)
)
def __get_data(method, id, include_unknown_references=False) -> dict:

Expand Down

0 comments on commit 69e53c9

Please sign in to comment.