From 15a0286d47a54dfb970bebf1db350d82b90fb6bc Mon Sep 17 00:00:00 2001 From: Elvis Stansvik Date: Sun, 3 May 2015 11:43:48 +0200 Subject: [PATCH] Signal handlers to stop in shutdown(). --- pymodbus/server/sync.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pymodbus/server/sync.py b/pymodbus/server/sync.py index d2d2ca8be..0b915bef0 100644 --- a/pymodbus/server/sync.py +++ b/pymodbus/server/sync.py @@ -258,6 +258,15 @@ def process_request(self, request, client): _logger.debug("Started thread to serve client at " + str(client)) SocketServer.ThreadingTCPServer.process_request(self, request, client) + def shutdown(self): + ''' Stops the serve_forever loop. + + Overridden to signal handlers to stop. + ''' + for thread in self.threads: + thread.running = False + SocketServer.ThreadingTCPServer.shutdown(self) + def server_close(self): ''' Callback for stopping the running server '''