lib.FileContext.open(): Add method

Add an async open() method which should allow to do what __init__()
couldn't, because it's not async, and to match the already existing
.close(). It's called by __aenter__() __aexit__() if the FileContext
is instantiated as context manager, or at will when the user finds it
a good idea.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-04-22 07:55:44 +02:00
commit 58f7997bc6
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61
3 changed files with 51 additions and 33 deletions

View file

@ -35,6 +35,10 @@ class AsyncSSH(Base):
self.__connect_timeout = connect_timeout
self.__conn: asyncssh.SSHClientConnection|None = None
async def _open(self) -> None:
await super()._open()
await self._conn
async def _close(self) -> None:
if self.__conn is not None:
try: