Commit bee475e
committed
test: deterministically cover message_router closed-stream handler
Replace the two remaining `lax no cover` pragmas with a unit test that
deterministically triggers the race the handler defends against.
The scenario: sse_writer receives a JSONRPCResponse and breaks its
async-for loop; its finally block pops _request_streams. If
message_router is concurrently routing a trailing message to the same
request_id, the membership check passes but send() hits a closed
receiver. Under xdist the scheduler contention made this fire ~15% of
the time — enough to break strict-no-cover but not enough to rely on.
The new test injects a closed-receiver stream directly into
_request_streams, routes a message, and asserts the handler popped the
stale entry. No scheduler timing involved.
Also removed `# pragma: no cover` from `except Exception` in
standalone_sse_writer (line 717) — the thread-based GET stream tests
reliably cover it (both sequential and xdist). It was only unhit on
main because subprocess tests couldn't see into the subprocess.
Net: 0 lax no cover added, 2 more no cover removed.1 parent b9b1656 commit bee475e
2 files changed
+42
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
715 | 715 | | |
716 | 716 | | |
717 | 717 | | |
718 | | - | |
719 | | - | |
720 | | - | |
721 | | - | |
722 | | - | |
| 718 | + | |
723 | 719 | | |
724 | 720 | | |
725 | 721 | | |
| |||
1019 | 1015 | | |
1020 | 1016 | | |
1021 | 1017 | | |
1022 | | - | |
1023 | | - | |
1024 | | - | |
1025 | | - | |
1026 | | - | |
1027 | | - | |
1028 | | - | |
| 1018 | + | |
1029 | 1019 | | |
1030 | 1020 | | |
1031 | 1021 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1705 | 1705 | | |
1706 | 1706 | | |
1707 | 1707 | | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
1708 | 1748 | | |
1709 | 1749 | | |
1710 | 1750 | | |
| |||
0 commit comments