Skip to content

Commit

Permalink
Merge pull request #3644 from davep/chunk-writes-on-windows
Browse files Browse the repository at this point in the history
Chunk writes on Windows
  • Loading branch information
davep authored Nov 7, 2023
2 parents f0fd8d4 + 7dcf014 commit c7cf028
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed

- Duplicate CSS errors when parsing CSS from a screen https://github.com/Textualize/textual/issues/3581
- Fixed visual glitched characters on Windows due to Python limitation https://github.com/Textualize/textual/issues/2548

### Changed

Expand Down
17 changes: 16 additions & 1 deletion src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2526,7 +2526,22 @@ def _display(self, screen: Screen, renderable: RenderableType | None) -> None:
except Exception as error:
self._handle_exception(error)
else:
self._driver.write(terminal_sequence)
if WINDOWS:
# Combat a problem with Python on Windows.
#
# https://github.com/Textualize/textual/issues/2548
# https://github.com/python/cpython/issues/82052
CHUNK_SIZE = 8192
write = self._driver.write
for chunk in (
terminal_sequence[offset : offset + CHUNK_SIZE]
for offset in range(
0, len(terminal_sequence), CHUNK_SIZE
)
):
write(chunk)
else:
self._driver.write(terminal_sequence)
finally:
self._end_update()

Expand Down

0 comments on commit c7cf028

Please sign in to comment.