def disconnect(self): """Close all sockets""" if dltlib.dlt_client_cleanup(ctypes.byref(self), self.verbose) == DLT_RETURN_ERROR: raise RuntimeError("Could not cleanup DLTClient") if self._connected_socket: try: self._connected_socket.shutdown(socket.SHUT_RDWR) except IOError: pass except Exception: # pylint: disable=broad-except logger.exception( "Unexpected exception while shutting down connection") try: self._connected_socket.close() except IOError: pass except Exception: # pylint: disable=broad-except logger.exception("Unexpected exception while disconnecting")
def __del__(self): if dltlib.dlt_client_cleanup(ctypes.byref(self), self.verbose) == DLT_RETURN_ERROR: raise RuntimeError("Could not cleanup DLTClient") self.disconnect()