Skip to content

Commit

Permalink
lockdown: fix reconnection on remote close for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenGemin authored and doronz88 committed May 5, 2024
1 parent 894f676 commit c069825
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pymobiledevice3/lockdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import os
import plistlib
import sys
import tempfile
import time
from abc import ABC, abstractmethod
Expand Down Expand Up @@ -56,15 +57,21 @@ def _reconnect_on_remote_close(f):
transmitted). When this happens, we'll attempt to reconnect.
"""

def _reconnect(self: 'LockdownClient'):
self._reestablish_connection()
self.validate_pairing()

@wraps(f)
def _inner_reconnect_on_remote_close(*args, **kwargs):
try:
return f(*args, **kwargs)
except (BrokenPipeError, ConnectionTerminatedError):
self: LockdownClient = args[0]

self._reestablish_connection()
self.validate_pairing()
_reconnect(args[0])
return f(*args, **kwargs)
except ConnectionAbortedError:
if sys.platform != 'win32':
raise
_reconnect(args[0])
return f(*args, **kwargs)

return _inner_reconnect_on_remote_close
Expand Down

0 comments on commit c069825

Please sign in to comment.