mirror of
https://github.com/CyberMind-FR/secubox-deb.git
synced 2026-07-29 12:34:38 +00:00
refactor(podcaster): use asyncio.wait to await cancelled download (review #853)
Replace `try: await cur except BaseException: pass` with `await asyncio.wait({cur})`
so awaiting the cancelled download's unwind no longer swallows cancellation of
the request handler itself (client disconnect). Pure idiom cleanup; behaviour
for the cancel-and-restart path is unchanged.
Co-Authored-By: Gerald KERMA <devel@cybermind.fr>
This commit is contained in:
parent
e0ec3ab417
commit
0e41813e57
|
|
@ -562,10 +562,10 @@ async def download(ep_id: int):
|
|||
cur = _inflight.get(ep_id)
|
||||
if cur is not None and not cur.done():
|
||||
cur.cancel()
|
||||
try:
|
||||
await cur
|
||||
except BaseException: # noqa: BLE001 — CancelledError or any unwind error
|
||||
pass
|
||||
# Wait for the cancelled task to unwind WITHOUT re-raising its
|
||||
# CancelledError/exception here (asyncio.wait swallows the awaitee's
|
||||
# outcome but still propagates cancellation of *this* handler).
|
||||
await asyncio.wait({cur})
|
||||
# Manual (re)download resets the auto-retry budget so a wedged/failed
|
||||
# episode gets a fresh set of tries.
|
||||
store.set_episode(ep_id, state="queued", progress=0, error=None, attempts=0)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user