Skip to content

Commit

Permalink
fix: Skip properties post when transport is closed
Browse files Browse the repository at this point in the history
If the connection has been terminated, the properties could not be read.
  • Loading branch information
rumpelsepp committed Oct 10, 2022
1 parent b7f5394 commit 370b70e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/gallia/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ async def setup(self, args: Namespace) -> None:
)

async def teardown(self, args: Namespace) -> None:
if args.properties is True:
if args.properties is True and not self.ecu.transport.is_closed:
path = self.artifacts_dir.joinpath(FileNames.PROPERTIES_POST.value)
async with aiofiles.open(path, "w") as file:
await file.write(json.dumps(await self.ecu.properties(True), indent=4))
Expand Down
1 change: 1 addition & 0 deletions src/gallia/transports/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def __init__(self, target: TargetURI) -> None:
self.mutex = asyncio.Lock()
self.logger = get_logger(self.SCHEME)
self.target = target
self.is_closed = False

def __init_subclass__(
cls,
Expand Down
1 change: 1 addition & 0 deletions src/gallia/transports/doip.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ async def connect(
return cls(t, port, config, conn)

async def close(self) -> None:
self.is_closed = True
await self._conn.close()

async def read(
Expand Down
1 change: 1 addition & 0 deletions src/gallia/transports/tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async def connect(
return cls(t, reader, writer)

async def close(self) -> None:
self.is_closed = True
self.writer.close()
await self.writer.wait_closed()

Expand Down

0 comments on commit 370b70e

Please sign in to comment.