mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-14 04:02:26 +00:00
fix(gateway): use monotonic deadlines in QR onboarding flows
This commit is contained in:
parent
73d6371762
commit
6e8f1e09a9
6 changed files with 105 additions and 13 deletions
|
|
@ -4591,12 +4591,12 @@ def _poll_registration(
|
|||
Returns dict with app_id, app_secret, domain, open_id on success.
|
||||
Returns None on failure.
|
||||
"""
|
||||
deadline = time.time() + expire_in
|
||||
deadline = time.monotonic() + expire_in
|
||||
current_domain = domain
|
||||
domain_switched = False
|
||||
poll_count = 0
|
||||
|
||||
while time.time() < deadline:
|
||||
while time.monotonic() < deadline:
|
||||
base_url = _accounts_base_url(current_domain)
|
||||
try:
|
||||
res = _post_registration(base_url, {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import logging
|
|||
import mimetypes
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
import uuid
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
|
@ -1562,12 +1563,11 @@ def qr_scan_for_bot_info(
|
|||
print(" Fetching configuration results...", end="", flush=True)
|
||||
|
||||
# ── Step 3: Poll for result ──
|
||||
import time
|
||||
deadline = time.time() + timeout_seconds
|
||||
deadline = time.monotonic() + timeout_seconds
|
||||
query_url = f"{_QR_QUERY_URL}?scode={urllib.parse.quote(scode)}"
|
||||
poll_count = 0
|
||||
|
||||
while time.time() < deadline:
|
||||
while time.monotonic() < deadline:
|
||||
try:
|
||||
req = urllib.request.Request(query_url, headers={"User-Agent": "HermesAgent/1.0"})
|
||||
with urllib.request.urlopen(req, timeout=10) as resp:
|
||||
|
|
|
|||
|
|
@ -1037,11 +1037,11 @@ async def qr_login(
|
|||
except Exception as _qr_exc:
|
||||
print(f"(终端二维码渲染失败: {_qr_exc},请直接打开上面的二维码链接)")
|
||||
|
||||
deadline = time.time() + timeout_seconds
|
||||
deadline = time.monotonic() + timeout_seconds
|
||||
current_base_url = ILINK_BASE_URL
|
||||
refresh_count = 0
|
||||
|
||||
while time.time() < deadline:
|
||||
while time.monotonic() < deadline:
|
||||
try:
|
||||
status_resp = await _api_get(
|
||||
session,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue