Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
fix: handle external cancel on discard
NTFSvolumef6b3a59717a5
diff --git a/cyberdrop_dl/aio.py b/cyberdrop_dl/aio.pyindex 18d12476f..956e84a54 100644--- a/cyberdrop_dl/aio.py+++ b/cyberdrop_dl/aio.py@@ -593,15 +593,24 @@ async def backgroud_task(await discard(task)+def current_task() -> asyncio.Task[Any]:+ task = asyncio.current_task()+ assert task is not None+ return task++def discard(fut: asyncio.Future[Any], /, grace_timeout: float = 0.01) -> asyncio.Future[None]:- async def kill() -> None:+ async def wait_or_cancel() -> None:if fut.done():returntry:async with asyncio.timeout(grace_timeout):await fut+ except asyncio.CancelledError:+ if not fut.done() or current_task().cancelling() > 0:+ raiseexcept TimeoutError:return- return asyncio.shield(kill())+ return asyncio.shield(wait_or_cancel())