summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mscp/mscp.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/mscp/mscp.py b/mscp/mscp.py
index df39dbd..e1d2bc8 100644
--- a/mscp/mscp.py
+++ b/mscp/mscp.py
@@ -35,6 +35,20 @@ class mscp:
self.dst_path = None
self.state = _STATE_INIT
+ def __del__(self):
+
+ if not hasattr(self, "state"):
+ return # this instance failed on mscp_init
+
+ if self.state == _STATE_RUNNING:
+ self.stop()
+ if self.state == _STATE_STOPPED:
+ self.join()
+ if self.state == _STATE_JOINED:
+ self.cleanup()
+ if self.state == _STATE_CLEANED:
+ self.free()
+
def _state2str(self):
return _state_str[self.state]