Skip to content

Commit

Permalink
Added mechanism to determine if server did not start cleanly
Browse files Browse the repository at this point in the history
  • Loading branch information
couling authored and janiversen committed Jun 4, 2023
1 parent 9542a73 commit 9bc064a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pymodbus/server/async_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,9 +663,11 @@ async def serve_forever(self):
try:
await self.server.serve_forever()
except asyncio.exceptions.CancelledError:
self.serving.set_result(False)
raise
except Exception as exc: # pylint: disable=broad-except
Log.error("Server unexpected exception {}", exc)
self.serving.set_result(False)
else:
raise RuntimeError(
"Can't call serve_forever on an already running server object"
Expand Down Expand Up @@ -836,9 +838,11 @@ async def serve_forever(self):
**self.factory_parms,
)
except asyncio.exceptions.CancelledError:
self.serving.set_result(False)
raise
except Exception as exc:
Log.error("Server unexpected exception {}", exc)
self.serving.set_result(False)
raise RuntimeError(exc) from exc
Log.info("Server(UDP) listening.")
self.serving.set_result(True)
Expand Down

0 comments on commit 9bc064a

Please sign in to comment.