Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
cd775bdb
Unverified
Commit
cd775bdb
authored
Jan 24, 2026
by
7. Sun
Committed by
GitHub
Jan 24, 2026
Browse files
[Tests] Replace flaky sleep with polling in test_background_cancel (#32986)
Signed-off-by:
7. Sun
<
jhao.sun@gmail.com
>
parent
da5e7b12
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
6 deletions
+19
-6
tests/v1/entrypoints/openai/serving_responses/test_stateful.py
.../v1/entrypoints/openai/serving_responses/test_stateful.py
+19
-6
No files found.
tests/v1/entrypoints/openai/serving_responses/test_stateful.py
View file @
cd775bdb
...
...
@@ -70,15 +70,28 @@ async def test_background_cancel(client: openai.AsyncOpenAI):
assert
response
.
status
==
"queued"
# Cancel the response before it is completed.
# FIXME: This test can be flaky.
await
asyncio
.
sleep
(
0.5
)
# Poll until the response is no longer queued (started processing) or timeout
loop
=
asyncio
.
get_running_loop
()
start_time
=
loop
.
time
()
max_wait_seconds
=
5.0
poll_interval
=
0.1
while
loop
.
time
()
-
start_time
<
max_wait_seconds
:
response
=
await
client
.
responses
.
retrieve
(
response
.
id
)
if
response
.
status
!=
"queued"
:
# Started processing or completed - try to cancel
break
await
asyncio
.
sleep
(
poll_interval
)
response
=
await
client
.
responses
.
cancel
(
response
.
id
)
assert
response
.
status
==
"cancelled"
# Make sure the response status remains unchanged.
await
asyncio
.
sleep
(
5
)
response
=
await
client
.
responses
.
retrieve
(
response
.
id
)
assert
response
.
status
==
"cancelled"
# Make sure the response status remains unchanged after some time.
max_retries
=
10
for
_
in
range
(
max_retries
):
await
asyncio
.
sleep
(
0.5
)
response
=
await
client
.
responses
.
retrieve
(
response
.
id
)
# Verify status is still cancelled
assert
response
.
status
==
"cancelled"
@
pytest
.
mark
.
asyncio
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment