Allow user to set a request timeout - #178
Conversation
| timeout=timeout | ||
| ) | ||
| return self.parse_response(resp) | ||
| except requests.exceptions.Timeout: |
There was a problem hiding this comment.
I don't think we should be catching and re-raising a custom Timeout exception.
Just let the request Timeout bubble up.
There was a problem hiding this comment.
I was having trouble creating a test for this. The requests_mock package doesn't trigger timeouts when you do a slowed down response using time.sleep. You can raise a requests.exception with the mock, but our library doesn't really take any action based on that exception. I figured since we are using timeout as one of the parameters that we are passing in now, we could have our custom exception for our library. And its easier to test, since our library does some action based on the exception.
There was a problem hiding this comment.
Shouldn't need to use time.sleep, requests-mock has a dedicated method of simulating timeouts.
https://requests-mock.readthedocs.io/en/latest/response.html#raising-exceptions.
I can try to set this up as a pytest fixture so it's easy to use/re-use in our tests.
There was a problem hiding this comment.
@Kilo59 I'm gonna try a different approach and see if I intercept the http request and supply my own response function. If that doesn't work, I'll see if I can put spy to make sure that we are passing down the timeout value.
| @@ -0,0 +1,25 @@ | |||
| name: Run tests from Forked Repo | |||
There was a problem hiding this comment.
@ShariqT nice work.
I totally forgot about this problem.
| @@ -0,0 +1 @@ | |||
| TIMEOUT_DEFAULT = 30 | |||
There was a problem hiding this comment.
I would assume 30 seconds it a reasonable default. Still seems hight to me but much better than never/infinite.
Fixes #162
TODO