Skip to content

ci(windows): test_echo_thin_waist fails via unraisable ResourceWarning / tracemalloc (demos) #1541

Description

@acul71

Summary

windows (3.12, demos) failed on PR #1532 CI with:

tests/examples/test_echo_thin_waist.py::test_echo_example_starts_and_prints_thin_waist

Job: https://github.com/libp2p/py-libp2p/actions/runs/34793308970/job/103821521009
SHA: f95e378d (ICE-Lite follow-up; does not touch this test or echo demo)

Same PR: tox (3.10–3.13, demos) and windows (3.11/3.13, demos) passed. Only windows 3.12 demos failed (1 failed / 191 passed).

What the logs show (not a Thin-Waist assert)

There is no Did not capture peer ID / multiaddr / waiting assertion failure. The reported failure is:

ExceptionGroup: multiple unraisable exception warnings (3 sub-exceptions)
...
File ".../_pytest/unraisableexception.py", line 128, in unraisable_hook
    tracemalloc_tb = "\n" + tracemalloc_message(unraisable.object)
File ".../_pytest/tracemalloc.py", line 13, in tracemalloc_message
    tb = tracemalloc.get_object_traceback(source)
AttributeError: partially initialized module 'tracemalloc' has no attribute
'get_object_traceback' (most likely due to a circular import)
RuntimeError: Failed to process unraisable exception

Preceding context also shows:

ResourceWarning: unclosed <socket.socket ... laddr=('127.0.0.1', 65353),
raddr=('127.0.0.1', 65348)>

So the child echo process / pipes left unclosed sockets; pytest then failed while processing those unraisable/ResourceWarnings (tracemalloc hook blow-up), not because Thin Waist lines were missing.

Likely aggravated by #1533 enabling filterwarnings = ["error::ResourceWarning"] in pyproject.toml.

Is the test well written / event-driven?

Partially event-driven, cleanup is not.

tests/examples/test_echo_thin_waist.py:

Aspect Assessment
Ready signal Event-driven on stdout: reads lines until "Waiting for incoming connections..." (also captures I am … / echo-demo -d …). Good.
Empty-read loop Polls with time.sleep(0.05) + wall-clock timeout_s = 8.0 when readline() returns empty — acceptable for subprocess stdout, not Trio.
Docstring Claims “using Trio primitives” but the test is sync subprocess.Popen + time — misleading.
Unused fixtures monkeypatch, tmp_path unused.
Teardown terminate() then immediate kill() with no wait() / no closing stdout — classic source of unclosed sockets / pipes → ResourceWarning on Windows.
Isolation Spawns a real module process; fine for a smoke test, but teardown must be clean under the new ResourceWarning-as-error CI guard.

Verdict: The readiness check is reasonably event-driven. The failure mode is teardown / resource-leak fragility under Windows + pytest unraisable + error::ResourceWarning, not a regression of Thin Waist printing. Unrelated to WebRTC ICE-Lite (#1532 / #1512).

Suggested fix

  1. In test_echo_thin_waist: after seeing the waiting line, close stdout, proc.wait(timeout=…), only then kill if needed; use try/finally that always reaps the child.
  2. Optionally mark/filter this subprocess smoke path, or migrate to an in-process Trio listener fixture (true event-driven, no subprocess sockets).
  3. Re-run windows (3.12, demos); treat intermittent unraisable/tracemalloc as a flake until teardown is fixed.

Refs

Activity

  1. yashksaini-coder commented on Sep 14, 2026

    @yashksaini-coder
    Contributor

    @acul71 Fixing this one seperately

  2. yashksaini-coder commented on Sep 14, 2026

    @yashksaini-coder
    Contributor

    Opened #1542 — reaps the echo subprocess cleanly (terminate → wait(timeout) → kill fallback → close stdout), per your suggestion; also drops the misleading Trio note and unused fixtures. Verified 0 ResourceWarnings under -W error::ResourceWarning. Review welcome. cc @acul71

  3. added a commit that references this issue on Sep 14, 2026
    6853ee5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions