python-trio / python-trio/trio

[minor] Test helper fill_socket is probably unreliable on Windows

Open
#561 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

polish Windows
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.