Open soukun-kuno opened 1 year ago
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
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
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/