-
Notifications
You must be signed in to change notification settings - Fork 12
Add DynamicTimeoutFunction
#383
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
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.
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
|
||
For POST on endpoint v2/datasets/whatever/items timeout is proportional to the size of the content. | ||
For everything else return fixed 30.""" | ||
if isinstance(content, bytes) and method == 'POST' and url.endswith('v2/datasets/whatever/items'): |
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.
The dynamic timeout function only handles content that is of type bytes, but the tests pass strings (e.g., 'abcd'). To ensure the expected custom timeouts (e.g., 5, 9), update the type check or convert the content to bytes.
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
('content', 'expected_timeout'), | ||
[ | ||
pytest.param('abcd', 5, id='Small payload'), | ||
pytest.param('abcd' * 10000, 9, id='Payload in the dynamic timeout interval interval'), |
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 test case id contains a repeated phrase ('interval interval'); consider revising it to remove the duplication.
pytest.param('abcd' * 10000, 9, id='Payload in the dynamic timeout interval interval'), | |
pytest.param('abcd' * 10000, 9, id='Payload in the dynamic timeout interval'), |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
Close din favor of: #384 |
Add
DynamicTimeoutFunction
to enable custom timeouts for individual requests.This allows users of
ApifyClientAsync
andApifyClient
to pass optional argumentget_dynamic_timeout
which is a function that can get suitable timeout for http requests to Apify API. Clients will use this function to set timeout for the requests.Clients behave the same as before if the optional argument is not used.
Enables fix of: apify/crawlee-python#1132