Skip to content

Commit a9218c8

Browse files
aronzeke
authored andcommitted
Do not poll if blocking prediction has succeeded
1 parent 5c7f210 commit a9218c8

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

replicate/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ async def async_run(
184184
Run a model and wait for its output asynchronously.
185185
"""
186186

187-
return await async_run(self, ref, input, use_file_output=use_file_output, **params)
187+
return await async_run(
188+
self, ref, input, use_file_output=use_file_output, **params
189+
)
188190

189191
def stream(
190192
self,

replicate/run.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ async def async_run(
111111
if version and (iterator := _make_async_output_iterator(version, prediction)):
112112
return iterator
113113

114-
await prediction.async_wait()
114+
if not (is_blocking and prediction.status != "starting"):
115+
await prediction.async_wait()
115116

116117
if prediction.status == "failed":
117118
raise ModelError(prediction)

0 commit comments

Comments
 (0)