Skip to content

Commit

Permalink
lockdown: add async contextmanager interface for LockdownClient
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenGemin committed Jun 26, 2024
1 parent e85fce9 commit e234172
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pymobiledevice3/lockdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,16 @@ def __repr__(self) -> str:
return f'<{self.__class__.__name__} ID:{self.identifier} VERSION:{self.product_version} ' \
f'TYPE:{self.product_type} PAIRED:{self.paired}>'

def __enter__(self):
def __enter__(self) -> 'LockdownClient':
return self

def __exit__(self, exc_type, exc_val, exc_tb):
def __exit__(self, exc_type, exc_val, exc_tb) -> None:
self.close()

async def __aenter__(self) -> 'LockdownClient':
return self

async def __aexit__(self, exc_type, exc_val, exc_tb) -> None:
self.close()

@property
Expand Down

0 comments on commit e234172

Please sign in to comment.