[Misc] Upgrade more code to Python 3.10 (#26463)

Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
This commit is contained in:
Cyrus Leung
2025-10-09 10:43:53 +01:00
committed by GitHub
parent e4791438ed
commit dc7976dd9f
7 changed files with 16 additions and 33 deletions
+6 -9
View File
@@ -18,6 +18,7 @@ On the client side, run:
import argparse
import asyncio
import contextlib
import gc
import importlib.util
import json
@@ -605,17 +606,13 @@ async def benchmark(
pbar = None if disable_tqdm else tqdm(total=len(input_requests))
# This can be used once the minimum Python version is 3.10 or higher,
# and it will simplify the code in limited_request_func.
# semaphore = (asyncio.Semaphore(max_concurrency)
# if max_concurrency else contextlib.nullcontext())
semaphore = asyncio.Semaphore(max_concurrency) if max_concurrency else None
semaphore = (
asyncio.Semaphore(max_concurrency)
if max_concurrency
else contextlib.nullcontext()
)
async def limited_request_func(request_func_input, session, pbar):
if semaphore is None:
return await request_func(
request_func_input=request_func_input, session=session, pbar=pbar
)
async with semaphore:
return await request_func(
request_func_input=request_func_input, session=session, pbar=pbar