新增post请求超时时间五分钟
This commit is contained in:
parent
8c3f2ffad0
commit
00789ba275
@ -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))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user