diff --git a/python/tvm/micro/project_api/client.py b/python/tvm/micro/project_api/client.py index f1eb115cfbbe..c9f889e9b6dd 100644 --- a/python/tvm/micro/project_api/client.py +++ b/python/tvm/micro/project_api/client.py @@ -85,17 +85,17 @@ def __init__( @property def is_shutdown(self): - return self.read_file is None + return self.read_file.closed def shutdown(self): - if self.is_shutdown: + if self.is_shutdown: # pylint: disable=using-constant-test return self.read_file.close() self.write_file.close() def _request_reply(self, method, params): - if self.is_shutdown: + if self.is_shutdown: # pylint: disable=using-constant-test raise ConnectionShutdownError("connection already closed") request = { diff --git a/python/tvm/micro/session.py b/python/tvm/micro/session.py index 8a51f1082dda..7d01baa75289 100644 --- a/python/tvm/micro/session.py +++ b/python/tvm/micro/session.py @@ -157,6 +157,8 @@ def __exit__(self, exc_type, exc_value, exc_traceback): if not self._exit_called: self._exit_called = True self.transport.__exit__(exc_type, exc_value, exc_traceback) + shutdown_func = self._rpc._sess.get_function("CloseRPCConnection") + shutdown_func() def _cleanup(self): self.__exit__(None, None, None)