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

Add support forall_errors to asyncio.create_connection #93973

Closed
Labels
@pamelafox

Description

@pamelafox

Feature or enhancement

As a result of the discussion on#74166,@iritkatriel added theall_errors keyword argument to socket.py:create_connection. When set to True, multiple exceptions are raised using an ExceptionGroup instead of a single OSError with the messages combined. I propose adding the sameall_errors keyword to asyncio.create_connection, which would raise an ExceptionGroup in the case of connection errors (not for other errors, however).

Pitch

An ExceptionGroup is much nicer to handle than parsing through a concatenated string. Anissue in the websockets library indicates that developers would like that for asyncio.create_connection as well. I personally ran into it myself as well.

Example usage:

async def check_ports(host: str, start: int, end: int, max=10):    for port in range(start, end):        try:            future = asyncio.open_connection(host=host, port=port, all_errors=True)            r, w = await asyncio.wait_for(future, timeout=timeout)            yield port            w.close()        except* ConnectionRefusedError:            pass        except* asyncio.TimeoutError:            pass

Previous discussion

Related discussion on:
#74166

I will send a PR with the proposed change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp