Skip to content

Commit

Permalink
Fix: Bug where it would exit automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
NanoSpicer committed Nov 28, 2023
1 parent a1cccfe commit 859ecf2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions knxdclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ async def connect(self, host: str = 'localhost', port: int = 6720, sock: Optiona
async def _read_raw_knxpacket(self) -> bytes:
length = int.from_bytes(await self._reader.readexactly(2), byteorder='big')
return await self._reader.readexactly(length)



async def run(self):
Expand Down Expand Up @@ -162,6 +161,7 @@ async def run(self):
self._current_response = packet
self._response_ready.set()
except asyncio.IncompleteReadError as e:
self._run_exited.set()
if self.closing:
logger.info("KNXd connection reached EOF. KNXd client is stopped.")
return
Expand All @@ -172,13 +172,12 @@ async def run(self):
# A connection, timeout or cancellation errors typically mean we cannot proceed further with this connection.
# Thus we abort the receive loop execution with the exception.
logger.error(f"A connection, timeout or cancellation error has occurred. Aborting current connection. {error}")
self._run_exited.set()
raise
except Exception as e:
logger.error("Error while receiving KNX packets:", exc_info=e)
raise
finally:
logger.debug("Exiting run loop")
self._run_exited.set()
raise


async def stop(self):
Expand Down

0 comments on commit 859ecf2

Please sign in to comment.