()
| 57 | |
| 58 | |
| 59 | async def main() -> None: |
| 60 | async with stdio_server() as (read_stream, write_stream): |
| 61 | await server.run(read_stream, write_stream, server.create_initialization_options()) |
| 62 | # Flush this process's coverage data before the clean-exit line below. Without this, the |
| 63 | # data is only written by coverage's atexit hook during interpreter teardown -- and on a |
| 64 | # slow Windows runner that can overrun the transport's termination grace, so the kill |
| 65 | # silently destroys the data file and the 100% gate trips on this module's subprocess-only |
| 66 | # lines. Saving here puts the write before the line the test synchronizes on: once the |
| 67 | # parent has seen "clean exit", the data is durably on disk and the escalation is harmless. |
| 68 | # Nothing measured may execute after the save (it would be unrecordable by construction), |
| 69 | # hence the excluded lines below. The branch is pragma'd because under coverage the |
| 70 | # instance always exists, and without coverage nothing is measured anyway. |
| 71 | cov = getattr(coverage.process_startup, "coverage", None) |
| 72 | if cov is not None: # pragma: no branch |
| 73 | # stop() is load-bearing twice over: it ends tracing, making itself the last |
| 74 | # recordable line, and it leaves nothing new for coverage's atexit re-save to flush -- |
| 75 | # so a kill landing during interpreter teardown cannot corrupt the file save() wrote |
| 76 | # (coverage opens it with sqlite journaling off; a torn rewrite would not roll back). |
| 77 | cov.stop() |
| 78 | cov.save() # pragma: lax no cover - untraced: stop() above already ended measurement |
| 79 | # Reached only when the run loop exits because stdin closed; if the process were terminated |
| 80 | # the test's stderr capture would not see this line. lax no cover: runs after the coverage |
| 81 | # save by design, so it can never appear covered. |
| 82 | print("stdio-echo: clean exit", file=sys.stderr, flush=True) # pragma: lax no cover |
| 83 | |
| 84 | |
| 85 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected