|
@@ -9,6 +9,7 @@ import random
|
|
|
import hashlib
|
|
|
import requests
|
|
|
import aiohttp
|
|
|
+import asyncio
|
|
|
import urllib.parse
|
|
|
|
|
|
|
|
@@ -188,13 +189,21 @@ def account_info_map(gh_id):
|
|
|
return ""
|
|
|
|
|
|
|
|
|
-async def request_etl(url, headers, json_data):
|
|
|
+async def request_etl(url, headers, json_data, retries=6):
|
|
|
"""
|
|
|
- 异步请求ETL
|
|
|
+ :param url:
|
|
|
+ :param headers:
|
|
|
+ :param json_data:
|
|
|
+ :param retries:
|
|
|
:return:
|
|
|
"""
|
|
|
async with aiohttp.ClientSession() as session:
|
|
|
- async with session.post(url, headers=headers, json=json_data, timeout=60) as response:
|
|
|
- response_data = await response.json()
|
|
|
- return response_data
|
|
|
-
|
|
|
+ for attempt in range(retries):
|
|
|
+ try:
|
|
|
+ async with session.post(url, headers=headers, json=json_data, timeout=120) as response:
|
|
|
+ return await response.json()
|
|
|
+ except asyncio.TimeoutError:
|
|
|
+ if attempt < retries - 1:
|
|
|
+ await asyncio.sleep(2) # 等待一段时间后重试
|
|
|
+ else:
|
|
|
+ raise
|