mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
test(responses): make the background stream cancel deterministic
A five-token response can complete before the cancel lands, which put the test back on the "Cannot cancel a completed response" path it used to swallow. Ask for a long generation so the cancel always beats completion, and assert the cancelled status unconditionally
This commit is contained in:
parent
36143b53f9
commit
b38516da88
1 changed files with 2 additions and 8 deletions
|
|
@ -162,7 +162,7 @@ def test_cancel_streaming_response():
|
|||
started = time.monotonic()
|
||||
stream = client.responses.create(
|
||||
model="gpt-5.5",
|
||||
input="just respond with the word 'ping'",
|
||||
input="count from 1 to 500, one number per line",
|
||||
stream=True,
|
||||
background=True,
|
||||
timeout=BACKGROUND_STREAM_ADMISSION_DEADLINE_SECONDS,
|
||||
|
|
@ -189,13 +189,7 @@ def test_cancel_streaming_response():
|
|||
)
|
||||
assert response_id is not None, f"no response event within {elapsed:.0f}s of streaming a background response"
|
||||
|
||||
try:
|
||||
cancel_response = client.responses.cancel(response_id)
|
||||
except BadRequestError as e:
|
||||
if "Cannot cancel a completed response" not in str(e):
|
||||
raise
|
||||
print("response completed before cancel=", e)
|
||||
return
|
||||
cancel_response = client.responses.cancel(response_id)
|
||||
print("CANCEL streaming response=", cancel_response)
|
||||
assert cancel_response.status == "cancelled"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue