Skip to content
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

Stop waiting forever when "currency not ready" #136

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

soukun-kuno
Copy link

the problem:
when the url is down, the library waits just about forever for the response that's doomed to fail. i highly suspect this is the cause of all the "currency not ready" issues here. it could literarily be like a minute.

the fix:
wait only 5 seconds instead. (this is just a random number i came up with. feel free to change it to something else that suits your need better.)

detailed explanation of why this is a good thing to do
https://datagy.io/python-requests-timeouts/

@Cruuncher
Copy link

Cruuncher commented Aug 2, 2023

When adding a timeout you should be catching ReadTimeout and ConnectTimeout exceptions. Otherwise this is going to change the behaviour of the package. In the event of a timeout, the timeout exception will be thrown out of this function rather than the intended RatesNotAvailableError

Little bit of info on catching timeouts in requests: https://stackoverflow.com/questions/16511337/correct-way-to-try-except-using-python-requests-module

@soukun-kuno
Copy link
Author

When adding a timeout you should be catching ReadTimeout and ConnectTimeout exceptions. Otherwise this is going to change the behaviour of the package. In the event of a timeout, the timeout exception will be thrown out of this function rather than the intended RatesNotAvailableError

Little bit of info on catching timeouts in requests: https://stackoverflow.com/questions/16511337/correct-way-to-try-except-using-python-requests-module

Thanks for the comment. Code modified to catch these exceptions and raise RatesNotAvailableError instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants