python-trio / python-trio/trio
[minor] Test helper fill_socket is probably unreliable on Windows
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.3k
- Forks
- 431
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 6
Description
Suppose you want to set up a socket where send blocks. It's helpful for testing; we do it in several places. Hence this helper from trio/_core/tests/test_io.py:
def fill_socket(sock):
try:
while True:
sock.send(b"x" * 65536)
except BlockingIOError:
pass
Except... as documented by @vstinner in this epic bit of debugging, apparently on Windows this can occasionally fail. (The send raises BlockingIOError... but if you call send again afterwards, then it succeeds, even if no-one has called recv.)
This hasn't bitten us yet, but I guess it probably will eventually. (Or maybe it has, but our tests are written in such a way that they accidentally passed?)
Here's Victor's current solution: https://github.com/python/cpython/pull/8327/files
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 in trio/_core/tests/test_io.py at fill_socket and inspect its usages in the tests. Read the linked CPython issue and pull request for the Windows behavior, then run the affected tests on Windows if available. Done means the helper reliably creates a socket whose send blocks without allowing a later send to succeed unexpectedly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking, operating-systems, testing-qa
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100