Skip to content

Commit 559a595

Browse files
committed
simplify cleanup in ssh_app_session
1 parent ff1e60a commit 559a595

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

gambaterm/ssh_app_session.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import os
88
import asyncio
9-
import subprocess
109
from concurrent.futures import ThreadPoolExecutor
1110
from contextlib import asynccontextmanager, contextmanager
1211
from typing import AsyncIterator, Iterator, TypeVar, Callable
@@ -32,8 +31,7 @@ async def _output_pipe_from_process(
3231
try:
3332
yield write_fd
3433
finally:
35-
await process.redirect_stdout(subprocess.PIPE)
36-
await asyncio.sleep(0)
34+
os.close(write_fd)
3735

3836

3937
@asynccontextmanager
@@ -50,8 +48,7 @@ async def _input_pipe_from_process(
5048
try:
5149
yield read_fd
5250
finally:
53-
await process.redirect_stdin(subprocess.PIPE)
54-
await asyncio.sleep(0)
51+
os.close(read_fd)
5552

5653

5754
@contextmanager
@@ -96,7 +93,7 @@ async def process_to_terminal(
9693
width, height = 80, 24
9794

9895
def _target() -> T:
99-
with open(write_fd, "w", newline="\r\n") as stream:
96+
with os.fdopen(write_fd, "w", newline="\r\n", closefd=False) as stream:
10097
ssh_term = RemoteTerminal(
10198
stream=stream,
10299
keyboard_fd=keyboard_fd,

0 commit comments

Comments
 (0)