python-trio / python-trio/trio
Better validate serve_listeners handling of weird edge cases
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.3k
- Forks
- 431
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 6
Description
Looking at https://github.com/twisted/twisted/pull/996/ led me to investigate more the difference between EMFILE and WSAEMFILE... the latter is the special "winsockets" version of EMFILE, and apparently they are actually different:
In [2]: errno.EMFILE
Out[2]: 24
In [3]: errno.WSAEMFILE
Out[3]: 10024
And right now serve_listeners has special handling for EMFILE, but not WSAEMFILE... so it's probably broken.
We should:
- Add the WSA variants to the list of errnos here: https://github.com/python-trio/trio/blob/7b7b7d1431644233a2c06928802be6cdca2e35c6/trio/_highlevel_serve_listeners.py#L11-L16
- Double-check if we need to modify the list in
SocketListener: https://github.com/python-trio/trio/blob/7b7b7d1431644233a2c06928802be6cdca2e35c6/trio/_highlevel_socket.py#L291-L311 - Modify our EMFILE test so that it actually provokes a real EMFILE, instead of a fake one like we do now: https://github.com/python-trio/trio/blob/7b7b7d1431644233a2c06928802be6cdca2e35c6/trio/tests/test_highlevel_serve_listeners.py#L102-L105
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the errno handling in trio/_highlevel_serve_listeners.py and compare it with SocketListener in trio/_highlevel_socket.py. Review test_highlevel_serve_listeners.py around the EMFILE test, then verify that the relevant Windows errno variants and a real EMFILE condition are covered by the tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100