Skip to content

Commit

Permalink
Merge pull request #976 from StephenGemin/bugfix/lockdown-remote-clos…
Browse files Browse the repository at this point in the history
…e-windows

lockdown: fix reconnection on remote close for windows
  • Loading branch information
doronz88 committed May 5, 2024
2 parents 894f676 + c069825 commit 27d0548
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 27d0548

Please sign in to comment.