feat: 按账号调度自动学习并让首页实时跟上状态
This commit is contained in:
@@ -17,7 +17,7 @@ from euniv.client import EUNIV, STUDY_API, USER_AGENT, YXT_API
|
||||
from euniv.collectors import collect_all, is_china, source_title
|
||||
from euniv.db import SessionLocal
|
||||
from euniv.models import ProxyNode, ProxyPoolSync
|
||||
from euniv.proxy import build_proxy_url
|
||||
from euniv.proxy import build_proxy_url, sync_httpx_client
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -170,8 +170,8 @@ def probe(scheme: str, host: str, port: int) -> tuple[bool, int, str]:
|
||||
samples: list[int] = []
|
||||
reasons: list[str] = []
|
||||
try:
|
||||
with httpx.Client(
|
||||
proxy=url,
|
||||
with sync_httpx_client(
|
||||
url,
|
||||
timeout=LATENCY_LIMIT,
|
||||
follow_redirects=True,
|
||||
headers={"User-Agent": USER_AGENT},
|
||||
@@ -202,9 +202,11 @@ def probe(scheme: str, host: str, port: int) -> tuple[bool, int, str]:
|
||||
|
||||
|
||||
def _short_reason(exc: BaseException) -> str:
|
||||
if isinstance(exc, (httpx.ConnectTimeout, httpx.TimeoutException)):
|
||||
from python_socks import ProxyConnectionError, ProxyTimeoutError
|
||||
|
||||
if isinstance(exc, (httpx.ConnectTimeout, httpx.TimeoutException, ProxyTimeoutError)):
|
||||
return "超时"
|
||||
if isinstance(exc, (httpx.ProxyError, httpx.ConnectError)):
|
||||
if isinstance(exc, (httpx.ProxyError, httpx.ConnectError, ProxyConnectionError)):
|
||||
return "无法连接"
|
||||
text = str(exc).strip() or type(exc).__name__
|
||||
return text[:200]
|
||||
|
||||
Reference in New Issue
Block a user