Skip to content

Commit e47a558

Browse files
committed
Expand SSHForwarder fix to cover both write() and write_eof()
This commit expands on commit 3d31c4c, fixing an assertion error in both write() and write_eof() when cleaning up SSHForwarder sessions. The previous fix only covered write_eof(). Thanks go to Mike Barry for reporting the remaining issue and helping to test the new fix.
1 parent 6de0ea3 commit e47a558

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

asyncssh/forward.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,13 @@ def set_peer(self, peer: 'SSHForwarder') -> None:
8585
def write(self, data: bytes) -> None:
8686
"""Write data to the transport"""
8787

88-
assert self._transport is not None
89-
self._transport.write(data)
88+
if not self._transport:
89+
return # pragma: no cover
90+
91+
try:
92+
self._transport.write(data)
93+
except OSError: # pragma: no cover
94+
pass
9095

9196
def write_eof(self) -> None:
9297
"""Write end of file to the transport"""

0 commit comments

Comments
 (0)