mirror of
https://github.com/upa/mscp.git
synced 2026-02-28 03:24:41 +08:00
add destructor to mscp class to call mscp_free()
This commit is contained in:
14
mscp/mscp.py
14
mscp/mscp.py
@@ -35,6 +35,20 @@ class mscp:
|
|||||||
self.dst_path = None
|
self.dst_path = None
|
||||||
self.state = _STATE_INIT
|
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):
|
def _state2str(self):
|
||||||
return _state_str[self.state]
|
return _state_str[self.state]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user