Skip to content

Commit

Permalink
use window_rows and window_cols
Browse files Browse the repository at this point in the history
  • Loading branch information
azliu0 committed Jan 29, 2025
1 parent 7421708 commit b57e260
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion modal/container_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ async def _send_window_resize(rows: int, cols: int):
# - 2 bytes for the number of columns (big-endian)
dims = struct.pack(">HH", rows, cols)
self.stdin.write(dims)
await self.stdin.drain(_is_resize=True)
await self.stdin.drain(_terminal_size=(rows, cols))

async with TaskContext() as tc:
stdout_task = tc.create_task(_write_to_fd_loop(self.stdout))
Expand Down
8 changes: 3 additions & 5 deletions modal/io_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def write_eof(self) -> None:

async def drain(
self,
_is_resize: bool = False, # internal option to send terminal window resize events
_terminal_size: Optional[tuple[int, int]] = None, # internal option to send terminal window resize events
) -> None:
"""Flush the write buffer and send data to the running process.
Expand All @@ -407,9 +407,6 @@ async def drain(
```
"""
data = bytes(self._buffer)
if _is_resize:
assert len(data) == 4, "unexpected buffer size for resize event" # rrww
assert self._object_type == "container_process", "resize event can only be sent for container processes"

self._buffer.clear()
index = self._get_next_index()
Expand All @@ -431,7 +428,8 @@ async def drain(
message=data,
message_index=index,
eof=self._is_closed,
is_resize=_is_resize,
window_rows=_terminal_size[0] if _terminal_size else None,
window_cols=_terminal_size[1] if _terminal_size else None,
),
),
)
Expand Down

0 comments on commit b57e260

Please sign in to comment.