diff --git a/src/dnp3_python/dnp3station/master_new.py b/src/dnp3_python/dnp3station/master_new.py index 28d8b4d..4da86ff 100644 --- a/src/dnp3_python/dnp3station/master_new.py +++ b/src/dnp3_python/dnp3station/master_new.py @@ -582,12 +582,28 @@ def start(self): self.master.Enable() def shutdown(self): - # print("=======before master del self.__dict", self.__dict__) + """ + Execute an orderly shutdown of the Master. + The debug messages may be helpful if errors occur during shutdown. + + Expected: + channel state change: SHUTDOWN + ms(1667103120775) INFO manager - Exiting thread (0) + + Note: + Note: Don't use `self.manager.Shutdown()`, otherwise + "Process finished with exit code 134 (interrupted by signal 6: SIGABRT)" + + Use `del self.master` instead of `self.master.Shutdown()`, otherwise + Process hanging + """ + sleep_before_master_shutdown = 2 _log.info(f"Master station shutting down in {sleep_before_master_shutdown} seconds...") time.sleep(sleep_before_master_shutdown) # Note: hard-coded sleep to avoid hanging process - del self.slow_scan - del self.fast_scan + # del self.master del self.master - del self.channel - del self.manager + # self.master.Shutdown() + self.channel.Shutdown() + + # self.manager.Shutdown() diff --git a/src/dnp3_python/dnp3station/outstation_new.py b/src/dnp3_python/dnp3station/outstation_new.py index 58eaa45..27eccd5 100644 --- a/src/dnp3_python/dnp3station/outstation_new.py +++ b/src/dnp3_python/dnp3station/outstation_new.py @@ -225,26 +225,23 @@ def start(self): def shutdown(self): """ - Execute an orderly shutdown of the Outstation. + Execute an orderly shutdown of the Outstation. + The debug messages may be helpful if errors occur during shutdown. - The debug messages may be helpful if errors occur during shutdown. + Expected: + ms(1667102887814) INFO server - Operation aborted. + ms(1667102887821) INFO manager - Exiting thread (0) + + Note: + Note: Don't use `self.manager.Shutdown()`, otherwise + Process finished with exit code 134 (interrupted by signal 6: SIGABRT) """ - # TODO: cannot shut down: see Outstation and master hang on shutdown #1 at - # https: // github.com / ChargePoint / pydnp3 / issues / 1 time.sleep(2) # Note: hard-coded sleep to avoid hanging process _outstation = self.get_outstation() - del _outstation - del self.channel - del self.log_handler - del self.outstation_application - del self.stack_config - del self.command_handler - del self.listener - del self.retry_parameters - # del self.manager - - self.manager.Shutdown() # Process finished with exit code 134 (interrupted by signal 6: SIGABRT) - # self.manager.__del__() # Process finished with exit code 134 (interrupted by signal 6: SIGABRT) + _outstation.Shutdown() + self.channel.Shutdown() + + # self.manager.Shutdown() @classmethod # TODO: Justify the necessity to use class method def get_outstation(cls):