def delete_client(self): if not self._client: return try: ref_count = sys.getrefcount(self._client) if ref_count != 2: # The getrefcount() hold 1 reference and self.client itself # hold 1 reference. raise error.NmstateInternalError( "_NmClient.delete_client() cannot release resources " "of NM.Client duo to other unreleased use.") self._nmclient_cleanup() except Exception: pass
def drop_cancellable(self, c): idx = self._cancellables.index(c) if idx == 0: raise error.NmstateInternalError('Cannot drop main cancellable') del self._cancellables[idx]
def __del__(self): if self._client: raise error.NmstateInternalError( "_NmClient.delete_client() should be explicitly called " "before python GC clean up the object." )