Skip to content
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

Allowed wait_socket_readable/writable to accept a file descriptor #824

Merged
merged 18 commits into from
Nov 16, 2024

Conversation

davidbrochart
Copy link
Contributor

Changes

Fixes #821.

It seems that anyio.wait_socket_readable(sock) and anyio.wait_socket_writable(sock) can not only accept a socket.socket but also the socket's file descriptor (int):

Checklist

If this is a user-facing code change, like a bugfix or a new feature, please ensure that
you've fulfilled the following conditions (where applicable):

  • You've added tests (in tests/) added which would fail without your patch
  • You've updated the documentation (in docs/, in case of behavior changes or new
    features)
  • You've added a new changelog entry (in docs/versionhistory.rst).

@davidbrochart
Copy link
Contributor Author

Not sure about the mypy error:

tests/test_sockets.py:1884: error: Argument 1 has incompatible type "object"; expected "socket | int"  [arg-type]

tests/test_sockets.py Outdated Show resolved Hide resolved
tests/test_sockets.py Outdated Show resolved Hide resolved
Co-authored-by: Alex Grönholm <alex.gronholm@nextday.fi>
@agronholm
Copy link
Owner

You really should install pre-commit locally.

@agronholm
Copy link
Owner

The docs build is now failing due to the typeshed annotation. I don't remember off hand how I've dealt with this previously.

@davidbrochart
Copy link
Contributor Author

I'm not sure why docs fails.

@agronholm
Copy link
Owner

agronholm commented Nov 12, 2024

The docs build is now failing due to the typeshed annotation. I don't remember off hand how I've dealt with this previously.

Ah, I remember now. Check out anyio._core._fileio to find out what I did about that.

docs/versionhistory.rst Outdated Show resolved Hide resolved
tests/test_sockets.py Outdated Show resolved Hide resolved
tests/test_sockets.py Outdated Show resolved Hide resolved
@agronholm
Copy link
Owner

Please stop force pushing your changes. It makes the review process much harder.

src/anyio/_backends/_asyncio.py Outdated Show resolved Hide resolved
src/anyio/_core/_sockets.py Outdated Show resolved Hide resolved
src/anyio/_core/_sockets.py Outdated Show resolved Hide resolved
Copy link
Owner

@agronholm agronholm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the proper Sphinx annotation for deprecations.

src/anyio/_core/_sockets.py Outdated Show resolved Hide resolved
src/anyio/_core/_sockets.py Outdated Show resolved Hide resolved
davidbrochart and others added 3 commits November 16, 2024 15:08
Co-authored-by: Alex Grönholm <alex.gronholm@nextday.fi>
Co-authored-by: Alex Grönholm <alex.gronholm@nextday.fi>
src/anyio/_core/_sockets.py Outdated Show resolved Hide resolved
src/anyio/_core/_sockets.py Outdated Show resolved Hide resolved
src/anyio/_core/_sockets.py Outdated Show resolved Hide resolved
tests/test_sockets.py Outdated Show resolved Hide resolved
tests/test_sockets.py Outdated Show resolved Hide resolved
tests/test_sockets.py Show resolved Hide resolved
@agronholm
Copy link
Owner

One more thing: the new functions need to be added to the API documentation too.

@agronholm agronholm merged commit e3acd02 into agronholm:master Nov 16, 2024
16 checks passed
@davidbrochart davidbrochart deleted the socket-fd branch November 16, 2024 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow anyio.wait_socket_readable to accept a file descriptor
4 participants