-
Notifications
You must be signed in to change notification settings - Fork 172
ensure cli event loop lives long enough for all tasks to finish #1199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ather with return_exceptions to allow in-flight backoffs to finish - Retry ServerDisconnectedError/ServerTimeoutError/ClientConnectionError/asyncio.TimeoutError for GET/HEAD/OPTIONS/PROPFIND/REPORT - Keep original rate-limit handling (429, Google 403 usageLimits) - In CLI, avoid cancelling sibling tasks so per-request backoff can complete; re-raise first failure after all tasks finish
7fbcfed
to
977b9c0
Compare
Rebased with minor tweaks (mostly formatting). |
Seems to mess up some TLS tests:
|
- `ClientConnectionError` in `aiohttp` can wrap SSL handshake and certificate verification errors - Retrying those hides the real cause and produced `TransientNetworkError` instead of the expected certificate error - Removing `ClientConnectionError` from the transient list lets SSL errors surface correctly
@WhyNotHugo tests now pass :) |
|
||
await asyncio.gather(*tasks) | ||
# `return_exceptions=True` ensures that the event loop lives long enough for | ||
# backoffs to be able to finish | ||
gathered = await asyncio.gather(*tasks, return_exceptions=True) | ||
# but now we need to manually check for and propogate a single failure after | ||
# allowing all tasks to finish in order to keep exit status non-zero | ||
failures = [e for e in gathered if isinstance(e, BaseException)] | ||
if failures: | ||
raise failures[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed that this is outside the async with aiohttp.TCPConnector(limit_per_host=16) as conn:
block.
The connector will be closed by the time this block is reached, so it will likely still lead to #1126.
I believe this solves #1126
aiohttp
disconnectsServerDisconnectedError
/ServerTimeoutError
/ClientConnectionError
/asyncio.TimeoutError
forGET
/HEAD
/OPTIONS
/PROPFIND
/REPORT
429
, Google403 usageLimits
)