Skip to content

The only downloader you need. 下载器的集大成者。

Revert "https://nuitka.net/posts/nuitka-this-week-1.html#coroutine-compatibility"

XiaoYouChR764a2ae10abb
diff --git a/features/bittorrent_pack/trackers.py b/features/bittorrent_pack/trackers.py
index f8fe6cb3..40402a08 100644
--- a/features/bittorrent_pack/trackers.py
+++ b/features/bittorrent_pack/trackers.py
@@ -54,8 +54,6 @@ async def fetchWebTrackers(sourceUrl: str) -> list[str]:
client = niquests.AsyncSession(headers=DEFAULT_HEADERS.copy(), timeout=30, happy_eyeballs=True)
client.trust_env = False
- # 像极了 Bilibili Pack, 这里在 nuitka 编译后 response.close() 也会导致没有报错的异常
-
try:
response = await client.get(
normalizedSource,
@@ -63,8 +61,11 @@ async def fetchWebTrackers(sourceUrl: str) -> list[str]:
verify=cfg.SSLVerify.value,
allow_redirects=True,
)
- response.raise_for_status()
- trackers = parseTrackerText(response.text)
+ try:
+ response.raise_for_status()
+ trackers = parseTrackerText(response.text)
+ finally:
+ response.close()
finally:
await client.close()
diff --git a/features/github_pack/config.py b/features/github_pack/config.py
index f897dce5..86815874 100644
--- a/features/github_pack/config.py
+++ b/features/github_pack/config.py
@@ -161,7 +161,10 @@ async def measureProxyLatencies() -> dict[str, int]:
allow_redirects=True,
stream=True,
)
- response.raise_for_status()
+ try:
+ response.raise_for_status()
+ finally:
+ await response.close()
latencies[site] = max(1, int((perf_counter() - startedAt) * 1000))
except Exception as e: