-
Notifications
You must be signed in to change notification settings - Fork 92
Added an option to specify a timeout duration #232
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
Conversation
Hello @sanders41! |
Hey @sanders41. Thanks so much for this addition as it is something we might consider on all repositories. In order to create a base example for other SKD's to follow, i have some requests to further improve your PR. We made a custom Error called Would it be possible to add some more tests? For example:
|
@bidoubiwa here is what I have done so far, let me know what you think.
This one I'm not exactly sure what you mean. I'll give a little more info here on how it works, then from that maybe you can give a little more info on what test you would want for this? When the client is instantiated the timeout value is passed to the |
I tried something new with this and it passes locally, but fails CI. My only thought right now is a difference in the way Mac and Linux are handling the error. In CI it is skipping the timeout error and falling trough to a connection error. When I can get a chance I will test this theory on one of my Linux computers. |
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.
Thanks so much for this throughout and really interesting research! About the tests with timeout 0, we can let it go until we find a good way to test it! It is not the most important one :)
This one I'm not exactly sure what you mean. I'll give a little more info here on how it works, then from that maybe you can give a little more info on what test you would want for this?
This one is really a basic test to ensure the right timeout is set.
client = meilisearch.Client("http://wrongurl:1234", MASTER_KEY, timeout=1)
assert client.config.timeout == 1
client = meilisearch.Client("http://wrongurl:1234", MASTER_KEY)
assert client.config.timeout == 10
If this is possible of course
I did some testing on both Mac and Linux and came up with a way to get the tests to work on both. Basically the issue came down to Linux was just responding so fast it didn't time out. I figured a way to slow the test down to give it a chance to time out on Linux also. |
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.
Based on this doc
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.
🔥 Great, great addition! Sorry for the delay 😅
bors merge |
Closes #231
I did not implement this with the Session as suggested in the issue simply because in the requests documentation there doesn't seem to be a way to set a default timeout for the session. It is possible with httpx to do this so maybe I'm missing something in requests. If anyone knows how and would rather use a session I can update it.
As an added bonus this does speed up the tests significantly be setting a timeout of 1 second on the communication error test.