fix: use get_running_loop, guard updatedAt, pass auth on wait_ready

This commit is contained in:
2026-05-14 23:56:15 +03:00
parent 21437c78ad
commit e7b44eb99a
+4 -3
View File
@@ -36,12 +36,13 @@ class MihomoClient:
await self.trigger_provider_refresh(name)
loop = asyncio.get_event_loop()
loop = asyncio.get_running_loop()
deadline = loop.time() + timeout
while loop.time() < deadline:
await asyncio.sleep(1)
data = await self.get_provider(name)
if data.get("updatedAt", "") != initial_ts:
new_ts = data.get("updatedAt")
if new_ts is not None and new_ts != initial_ts:
return data.get("proxies", [])
raise TimeoutError(f"Provider {name!r} did not refresh within {timeout}s")
@@ -60,7 +61,7 @@ class MihomoClient:
for i in range(retries):
try:
async with httpx.AsyncClient() as c:
resp = await c.get(f"{self._base_url}/version", timeout=3.0)
resp = await c.get(f"{self._base_url}/version", timeout=3.0, headers=self._headers)
resp.raise_for_status()
return
except Exception: