Engine.start() and stop() handle threading and socket lifecycle manually
Problems:
-> race conditions: _thread may be joined multiple times or while recv() is blocking. Closing sockets during a running loop can cause crashes or fatal errors in tests.
-> lifecycle management:
start()/stop() logic is duplicated and error-prone.
_running and _stop_event flags are manually handled.
--> inconsistent error handling:
Socket errors (pynng.NNGException) and processor exceptions propagate directly.
Possible Improvements
state machine pattern for engine life cycle?
context managers? (with Engine(...) as engine:)
idenmpotent start/stop
custom exception hierarchiy?
Engine.start() and stop() handle threading and socket lifecycle manually
Problems:
-> race conditions: _thread may be joined multiple times or while recv() is blocking. Closing sockets during a running loop can cause crashes or fatal errors in tests.
-> lifecycle management:
start()/stop() logic is duplicated and error-prone.
_running and _stop_event flags are manually handled.
--> inconsistent error handling:
Socket errors (pynng.NNGException) and processor exceptions propagate directly.
Possible Improvements
state machine pattern for engine life cycle?
context managers? (with Engine(...) as engine:)
idenmpotent start/stop
custom exception hierarchiy?