Skip to content

Commit 6a46036

Browse files
committed
ssh: catch ConnectionError in communicate
It seems like asyncssh is not handling ConnectionError internally when connecting to the target, so we catch it inside kirk. Also catch the asyncio.Error generic exception for all the other cases. Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com> Closes: #75
1 parent ff4ab5e commit 6a46036

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

libkirk/ssh.py

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

2020
try:
2121
import asyncssh
22-
import asyncssh.misc
2322

2423
class MySSHClientSession(asyncssh.SSHClientSession):
2524
"""
@@ -239,7 +238,7 @@ async def communicate(self, iobuffer: Optional[IOBuffer] = None) -> None:
239238

240239
self._logger.info("Maximum SSH sessions: %d", max_sessions)
241240
self._session_sem = asyncio.Semaphore(max_sessions)
242-
except asyncssh.misc.Error as err:
241+
except (asyncssh.Error, ConnectionError) as err:
243242
if not self._stop:
244243
raise SUTError(err) from err
245244

@@ -332,7 +331,7 @@ async def run_command(
332331

333332
panic = session.kernel_panic()
334333
stdout = session.get_output()
335-
except asyncssh.misc.ChannelOpenError as err:
334+
except asyncssh.Error as err:
336335
if not self._stop:
337336
raise SUTError(err)
338337
finally:

0 commit comments

Comments
 (0)