Skip to content

fix: avoid importing asyncio on Windows subprocess platform (#3551) - #3558

Closed
Tikbaan wants to merge 1 commit into
python-trio:mainfrom
Tikbaan:fix/avoid-asyncio-import-on-windows-subprocess-3551
Closed

Tikbaan wants to merge 1 commit into
python-trio:mainfrom
Tikbaan:fix/avoid-asyncio-import-on-windows-subprocess-3551

Conversation

@Tikbaan

@Tikbaan Tikbaan commented Oct 24, 2026

Copy link
Copy Markdown

trio._subprocess_platform.__init__ previously imported pipe from asyncio.windows_utils. Because asyncio/__init__.py imports the entire asyncio subsystem, importing Trio on Windows loaded over 30 asyncio modules into sys.modules, increasing startup latency by ~10%.

This reimplements windows_pipe in trio._subprocess_platform.windows directly on top of _winapi.CreateNamedPipe and _winapi.CreateFile, keeping Trio fully decoupled from asyncio during process initialization.

Fixes #3551.

…rio#3551)

trio._subprocess_platform.__init__ previously imported pipe from asyncio.windows_utils. Because asyncio/__init__.py imports the entire asyncio subsystem, importing trio on Windows loaded over 30 asyncio modules into sys.modules, increasing startup latency by ~10%.

This reimplements windows_pipe in trio._subprocess_platform.windows directly on top of _winapi.CreateNamedPipe and _winapi.CreateFile, keeping Trio fully decoupled from asyncio during process initialization.
@A5rocks

A5rocks commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

#3552 (comment)

@A5rocks A5rocks closed this Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

trio/_subprocess_platform/__init__.py imports entire asyncio on Windows

2 participants