Skip to content

Commit

Permalink
Fixes issue with process not being defined if there is an error durin…
Browse files Browse the repository at this point in the history
…g setup
  • Loading branch information
daveleroy committed Jan 15, 2024
1 parent 62dfe43 commit 656518b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion modules/dap/transports.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class StdioTransport(TransportStream):
command: list[str]
cwd: str|None = None
stderr: Callable[[str], None] | None = None
process: Process|None = None

async def setup(self):
self.log('transport', f'-- stdio transport: {self.command}')
Expand All @@ -137,21 +138,25 @@ def _log_stderr(self, data: str):
stderr(data)

def write(self, message: bytes) -> None:
assert self.process
self.process.stdin.write(message)
self.process.stdin.flush()

def readline(self) -> bytes:
assert self.process
if l := self.process.stdout.readline():
return l
raise EOFError

def read(self, n: int) -> bytes:
assert self.process
if l := self.process.stdout.read(n):
return l
raise EOFError

def dispose(self) -> None:
self.process.dispose()
if self.process:
self.process.dispose()


@dataclass
Expand Down

0 comments on commit 656518b

Please sign in to comment.