-
Notifications
You must be signed in to change notification settings - Fork 195
Stop waiting forever when "currency not ready" #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |||||
| from decimal import Decimal | ||||||
|
|
||||||
| import requests | ||||||
| from requests.exceptions import ReadTimeout, ConnectTimeout | ||||||
| import simplejson as json | ||||||
|
|
||||||
|
|
||||||
|
|
@@ -55,7 +56,10 @@ def get_rates(self, base_cur, date_obj=None): | |||||
| date_str = self._get_date_string(date_obj) | ||||||
| payload = {'base': base_cur, 'rtype': 'fpy'} | ||||||
| source_url = self._source_url() + date_str | ||||||
| response = requests.get(source_url, params=payload) | ||||||
| try: | ||||||
| response = requests.get(source_url, params=payload, timeout=5) | ||||||
|
||||||
| except (ReadTimeout, ConnectTimeout): | ||||||
|
||||||
| except (ReadTimeout, ConnectTimeout): | |
| except requests.exceptions.Timeout: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The try/except block is duplicated across three methods. Extract a helper method (e.g.
_safe_get) to reduce duplication and centralize timeout handling.