Skip to content

Commit da0bf7b

Browse files
authored
add env var to control timeout (InternLM#3291)
* add env var to control timeout * update * update * fix lint
1 parent 9f211a8 commit da0bf7b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

benchmark/profile_restful_api.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,18 @@
3030
from tqdm.asyncio import tqdm
3131
from transformers import AutoTokenizer, PreTrainedTokenizer, PreTrainedTokenizerBase, PreTrainedTokenizerFast
3232

33-
AIOHTTP_TIMEOUT = aiohttp.ClientTimeout(total=6 * 60 * 60)
33+
AIOHTTP_TIMEOUT = aiohttp.ClientTimeout(total=None)
34+
35+
_timeout_value = os.getenv('AIOHTTP_TIMEOUT', None)
36+
if _timeout_value is not None:
37+
try:
38+
_timeout_value = int(_timeout_value)
39+
if _timeout_value < 0:
40+
raise ValueError('AIOHTTP_TIMEOUT cannot be negative.')
41+
AIOHTTP_TIMEOUT = aiohttp.ClientTimeout(total=_timeout_value * 60 * 60)
42+
except ValueError as e:
43+
print(f'Invalid AIOHTTP_TIMEOUT: {e}.')
44+
AIOHTTP_TIMEOUT = aiohttp.ClientTimeout(total=None)
3445

3546
global args
3647

0 commit comments

Comments
 (0)