[Fix] Fix uvloop get_event_loop() is not suitable for 0.22.x (#13612)

Signed-off-by: lzy <tomlzy213@gmail.com>
Co-authored-by: lzy <tomlzy213@gmail.com>
This commit is contained in:
Zhi Yiliu
2025-11-25 01:20:00 +08:00
committed by GitHub
co-authored by lzy
parent 98b38de3f2
commit a95a38078b
9 changed files with 32 additions and 20 deletions
@@ -6,7 +6,6 @@ or
python -m unittest discover -s tests -p "test_*unit.py" -v
"""
import asyncio
import json
import unittest
import uuid
@@ -21,6 +20,7 @@ from sglang.srt.entrypoints.openai.protocol import (
)
from sglang.srt.entrypoints.openai.serving_chat import OpenAIServingChat
from sglang.srt.managers.io_struct import GenerateReqInput
from sglang.srt.utils import get_or_create_event_loop
class _MockTokenizerManager:
@@ -389,7 +389,7 @@ class ServingChatTestCase(unittest.TestCase):
break
return line
loop = asyncio.get_event_loop()
loop = get_or_create_event_loop()
line = loop.run_until_complete(collect_first_tool_chunk())
self.assertIsNotNone(line)
self.assertTrue(line.startswith("data: "))
@@ -564,7 +564,7 @@ class ServingChatTestCase(unittest.TestCase):
break
return line
loop = asyncio.get_event_loop()
loop = get_or_create_event_loop()
line = loop.run_until_complete(collect_first_tool_chunk())
self.assertIsNotNone(line)
self.assertTrue(line.startswith("data: "))