-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove 'retry' dependency and implement retries using 'requests' own …
…functionality
- Loading branch information
1 parent
83655e1
commit 4dc978e
Showing
5 changed files
with
61 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
import requests | ||
from requests.adapters import HTTPAdapter | ||
from urllib3 import Retry | ||
|
||
http_adapter = HTTPAdapter(max_retries=Retry(total=3)) | ||
|
||
|
||
def get_iati_versions(): | ||
session = requests.Session() | ||
session.mount('https://', http_adapter) | ||
versions_url = 'http://reference.iatistandard.org/201/codelists/' + \ | ||
'downloads/clv2/json/en/Version.json' | ||
versions = [d['code'] | ||
for d in requests.get(versions_url).json()['data']] | ||
versions = [ | ||
d['code'] | ||
for d in session.get(versions_url).json()['data'] | ||
] | ||
versions.reverse() | ||
return versions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
retry | ||
-e . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters