Skip to content

Simplify Windows write I/O around consoles on Windows 8+ #121940

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cmaloney opened this issue Jul 17, 2024 · 0 comments
Open

Simplify Windows write I/O around consoles on Windows 8+ #121940

cmaloney opened this issue Jul 17, 2024 · 0 comments
Labels
OS-windows topic-IO type-feature A feature request or enhancement

Comments

@cmaloney
Copy link
Contributor

cmaloney commented Jul 17, 2024

Feature or enhancement

Proposal:

In bpo-11395 from 2011, Windows Python needed to check on every write if a write was to a tty / console object and limit the size of the write to avoid an OS error on write. With Windows 8 and above, the Windows subsystem has been updated and this check is no longer necessary. It is also not necessary to split the write into smaller pieces (which resulted in gh-110913 and gh-82052).

Based on PEP 11, the last Windows 8 support ended in 2023, so the isatty + limited write size is no longer needed on any currently supported Windows platform (Pipes are still limited write size).

That large writes work is tested in test_os, test_write_windows_console

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

#55604 (comment)

Linked PRs

@cmaloney cmaloney added the type-feature A feature request or enhancement label Jul 17, 2024
cmaloney added a commit to cmaloney/cpython that referenced this issue Jul 17, 2024
This check was added for bpo-11395 in 2011. Versions of Windows before
Windows 8 required the check as write size to a tty was limited (
python#55604 (comment)).

Based on PEP 11, the last Windows 8 support ended in 2023, so this is no
longer needed on any currently supported windows platforms.

That large writes to console succeed is tested by
test_os.test_write_windows_console, which passes in my testing on
Windows 11.

It's possible there are still objects on windows which error on a write
too large, this leaves in place some code to handle (ex. Pipes and
ENOSPC). Write can also still be interrupted and resumed (EAGAIN, etc).

If there are other Windows objects or platform files which limit write
size, callers should wrap the `os.write` function.
cmaloney added a commit to cmaloney/cpython that referenced this issue Jul 17, 2024
This check was added for bpo-11395 in 2011. Versions of Windows before
Windows 8 required the check as write size to a tty was limited (
python#55604 (comment)).

Based on PEP 11, the last Windows 8 support ended in 2023, so this is no
longer needed on any currently supported windows platforms.

That large writes to console succeed is tested by
test_os.test_write_windows_console, which passes in my testing on
Windows 11.

It's possible there are still objects on windows which error on a write
too large, this leaves in place some code to handle (ex. Pipes and
ENOSPC). Write can also still be interrupted and resumed (EAGAIN, etc).

If there are other Windows objects or platform files which limit write
size, callers should wrap the `os.write` function.
cmaloney added a commit to cmaloney/cpython that referenced this issue Jul 17, 2024
This check was added for bpo-11395 in 2011. Versions of Windows before
Windows 8 required the check as write size to a tty was limited (
python#55604 (comment)).

Based on PEP 11, the last Windows 8 support ended in 2023, so this is no
longer needed on any currently supported windows platforms.

That large writes to console succeed is tested by
test_os.test_write_windows_console, which passes in my testing on
Windows 11.

It's possible there are still objects on windows which error on a write
too large, this leaves in place some code to handle (ex. Pipes and
ENOSPC). Write can also still be interrupted and resumed (EAGAIN, etc).

If there are other Windows objects or platform files which limit write
size, callers should wrap the `os.write` function.
cmaloney added a commit to cmaloney/cpython that referenced this issue Jul 17, 2024
This check was added for bpo-11395 in 2011. Versions of Windows before
Windows 8 required the check as write size to a tty was limited
(python#55604 (comment)).

Based on PEP 11, the last Windows 8 support ended in 2023, so this is no
longer needed on any currently supported windows platforms.

That large writes to console succeed is tested by
test_os.test_write_windows_console, which passes in my testing on
Windows 11.

It's possible there are still objects on windows which error on a write
too large, this leaves in place some code to handle (ex. Pipes and
ENOSPC). Write can also still be interrupted and resumed (EAGAIN, etc).

If there are other Windows objects or platform files which limit write
size, callers should wrap the `os.write` function.
cmaloney added a commit to cmaloney/cpython that referenced this issue Jul 26, 2024
 - Unify capping code to always respect character
   boundaries.
 - Make a soft cap rather than a hard limit
 - Make the cap for what _should_ be
   non-interactive / filesystem files 5 times that
   of interactive files (so big writes are faster)
 - Make write size for expected intractive to be
   1 MB (1024 * 1024), feels relatively responsive
   on my machines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS-windows topic-IO type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants