From d3a700398158a096950576837e294995a9ffe302 Mon Sep 17 00:00:00 2001 From: DoronZ Date: Tue, 16 Apr 2024 18:30:38 +0300 Subject: [PATCH] remote: fix triggering of `close()` when endpoint isn't connected --- pymobiledevice3/remote/remotexpc.py | 3 ++- pymobiledevice3/remote/tunnel_service.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pymobiledevice3/remote/remotexpc.py b/pymobiledevice3/remote/remotexpc.py index e04abe05..1ade61e6 100644 --- a/pymobiledevice3/remote/remotexpc.py +++ b/pymobiledevice3/remote/remotexpc.py @@ -52,7 +52,8 @@ async def connect(self, keep_alive: bool = True) -> None: await self._do_handshake() async def close(self) -> None: - await self.service_connection.aio_close() + if self.service_connection is not None: + await self.service_connection.aio_close() async def send_request(self, data: Mapping, wanting_reply: bool = False) -> None: xpc_wrapper = create_xpc_wrapper( diff --git a/pymobiledevice3/remote/tunnel_service.py b/pymobiledevice3/remote/tunnel_service.py index c9fe61e6..9700fd9b 100644 --- a/pymobiledevice3/remote/tunnel_service.py +++ b/pymobiledevice3/remote/tunnel_service.py @@ -895,7 +895,8 @@ async def start_tcp_tunnel(self) -> AsyncGenerator['TunnelResult', None]: await tunnel.stop_tunnel() async def close(self) -> None: - await self._service.aio_close() + if self._service is not None: + await self._service.aio_close() async def create_core_device_tunnel_service_using_rsd(