Skip to content

Async calls do synchronous sleeping while waiting for predictions. #229

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

Closed
LucasSwitz opened this issue Jan 22, 2024 · 3 comments · Fixed by #230
Closed

Async calls do synchronous sleeping while waiting for predictions. #229

LucasSwitz opened this issue Jan 22, 2024 · 3 comments · Fixed by #230

Comments

@LucasSwitz
Copy link

LucasSwitz commented Jan 22, 2024

It looks like the replicate client is synchronously waiting for predictions to finish during async methods.

replicate_client.async_run eventually calls this function that waits on the prediction: https://github.com/replicate/replicate-python/blob/main/replicate/run.py

prediction.wait() looks to be a synchronously spinning function: https://github.com/replicate/replicate-python/blob/main/replicate/prediction.py#L122

Am I understanding this correctly? Can we add a prediction.async_wait() that uses asyncio.wait() instead of time.sleep().

@LucasSwitz LucasSwitz changed the title Async calls do syncronous sleeping while waiting for predictions. Async calls do synchronous sleeping while waiting for predictions. Jan 22, 2024
@rohan-mehta
Copy link
Contributor

rohan-mehta commented Jan 23, 2024

#225 fixes this partly, wanted to note that prediction.output_iterator() still does a blocking sleep: https://github.com/replicate/replicate-python/blob/a3784c43503fa4f1193b7b5a1c84bca662088c6d/replicate/prediction.py#L200

That is called from _make_output_iterator in async_run.

@mattt
Copy link
Contributor

mattt commented Jan 23, 2024

Hi @LucasSwitz and @rohan-mehta. Thanks for reporting this. I just opened #230, which should address this. Please take a look and let me know if that works as expected.

mattt added a commit that referenced this issue Jan 27, 2024
Resolves #229

---------

Signed-off-by: Mattt Zmuda <[email protected]>
@mattt
Copy link
Contributor

mattt commented Jan 27, 2024

This is now available in version 0.23.1.

GothReigen pushed a commit that referenced this issue Feb 9, 2024
Resolves #229

---------

Signed-off-by: Mattt Zmuda <[email protected]>
GothReigen pushed a commit that referenced this issue Mar 11, 2024
Resolves #229

---------

Signed-off-by: Mattt Zmuda <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants