-
Notifications
You must be signed in to change notification settings - Fork 86
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
Implement wait_for_pending_update method #79
Conversation
e26582a
to
b4ede03
Compare
b4ede03
to
c502a34
Compare
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.
Sorry for my shitty comments, so bad that the python linter does not see that. I feel more and more disappointed by this linter 😂
But there is still one important comment 😬
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.
Could you add a test with interval = 0
?
return get_update | ||
sleep(interval_in_ms/1000) | ||
time_delta = datetime.now() - start_time | ||
elapsed_time = time_delta.seconds * 1000 + time_delta.microseconds / 1000 |
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.
What does this line do?
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.
It uses the timedelta object to calculate the number of milliseconds since the moment the user called the wait_for_pending_update method. time_delta is an instance of a timedelta object, this just converts it to an int in ms
Co-authored-by: Clémentine Urquizar <clementine@meilisearch.com>
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.
Could you add a test with interval = 0 ?
@bidoubiwa whats would seem like a logical behaviour for you in that test? I don't really know what I could check other than if the function works or not
return get_update | ||
sleep(interval_in_ms/1000) | ||
time_delta = datetime.now() - start_time | ||
elapsed_time = time_delta.seconds * 1000 + time_delta.microseconds / 1000 |
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.
It uses the timedelta object to calculate the number of milliseconds since the moment the user called the wait_for_pending_update method. time_delta is an instance of a timedelta object, this just converts it to an int in ms
@eskombro The only behavior is indeed for me that it should not crash. Since there are divisions going on I always prefer if the zero values are tested. |
Based on this discussion, SDKs must provide a method that waits synchronously for an update to be processed by MeiliSearch.
Parameters:
update_id
: id of the update to be waitedOptional parameters:
timeout_in_ms
max number of millisecond this method should wait before rising aTimeoutError
(default=2000ms)interval_in_ms
number of millisecond to set an interval of time this method should wait (sleep) between requests (default=10ms)tests
wait_for_pending_update
method in theIndex
classCloses #64