Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-135836: take into account staggered exceptions#135874

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
graingert wants to merge3 commits intopython:main
base:main
Choose a base branch
Loading
fromgraingert:take-into-account-staggered-exceptions
Draft
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletionsLib/asyncio/base_events.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1131,6 +1131,7 @@ async def create_connection(
infos = _interleave_addrinfos(infos, interleave)

exceptions = []
staggered_exceptions = []
if happy_eyeballs_delay is None:
# not using happy eyeballs
for addrinfo in infos:
Expand All@@ -1141,7 +1142,7 @@ async def create_connection(
except OSError:
continue
else: # using happy eyeballs
sock = (await staggered.staggered_race(
sock, _, staggered_exceptions = (await staggered.staggered_race(
(
# can't use functools.partial as it keeps a reference
# to exceptions
Expand All@@ -1152,10 +1153,15 @@ async def create_connection(
),
happy_eyeballs_delay,
loop=self,
))[0] # can't use sock, _, _ as it keeks a reference to exceptions
))

if sock is None:
exceptions = [exc for sub in exceptions for exc in sub]
for exc in staggered_exceptions:
if not (isinstance(exc, CancelledError) or exc in exceptions):
exceptions.append(exc)
del exc

try:
if all_errors:
raise ExceptionGroup("create_connection failed", exceptions)
Expand All@@ -1172,6 +1178,7 @@ async def create_connection(
', '.join(str(exc) for exc in exceptions)))
finally:
exceptions = None
staggered_exceptions = None

else:
if sock is None:
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
Fix :exc:`IndexError` in :meth:`asyncio.loop.create_connection` that could occur when the Happy Eyeballs algorithm resulted in an empty exceptions list during connection attempts, by capturing any exceptions raised by ``staggered_race``
Loading

[8]ページ先頭

©2009-2025 Movatter.jp