Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions python/cog/server/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,16 @@ async def predict_idempotent(
jsonable_encoder(task.result),
status_code=202,
)
else:
# even if not busy (use concurrency and max > 1) ,
# but someone put with the same prediction id repeatedly ,
# return its current state.
task = runner.get_predict_task(request.id)
if task:
return JSONResponse(
jsonable_encoder(task.result),
status_code=202,
)

# TODO: spec-compliant parsing of Prefer header.
respond_async = prefer == "respond-async"
Expand Down