新增post请求超时时间五分钟

This commit is contained in:
DELL 2026-03-02 15:13:46 +08:00
parent 8c3f2ffad0
commit 00789ba275

View File

@ -3,6 +3,7 @@ import logging as logger
import os
import random
import requests
from PIL import Image
from selenium.webdriver import DesiredCapabilities
from selenium.webdriver.firefox.options import Options
@ -25,10 +26,15 @@ def check_session(drive_path):
api = drive_path + '/graphql'
post_body = '{"query": "{ grid { maxSession, sessionCount } }"}'
try:
response = http_post(api, post_body)
# 添加超时控制5分钟 = 300秒
response = http_post(api, post_body, timeout=300)
data_body = json.loads(response.content.decode())
session_info = data_body['data']['grid']
return session_info
except requests.exceptions.Timeout as e:
logger.error("获取地址为 {} 的 Selenium 信息超时超过5分钟".format(drive_path))
logger.error(repr(e))
return None
except Exception as e:
logger.warning("获取地址为 {} 的 Selenium 信息失败,错误信息是:".format(drive_path))
logger.warning(repr(e))