Skip to content

Commit

Permalink
cli_common: remove inner usages of get_asyncio_loop().run()
Browse files Browse the repository at this point in the history
replace usages of `get_asyncio_loop().run()` with `asyncio.run()`

Close #1031
  • Loading branch information
doronz88 committed May 26, 2024
1 parent 6ebcd29 commit e535513
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pymobiledevice3/cli/cli_common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import datetime
import json
import logging
Expand All @@ -19,9 +20,8 @@
from pymobiledevice3.lockdown import LockdownClient, create_using_usbmux
from pymobiledevice3.osu.os_utils import get_os_utils
from pymobiledevice3.remote.remote_service_discovery import RemoteServiceDiscoveryService
from pymobiledevice3.tunneld import get_tunneld_devices
from pymobiledevice3.tunneld import async_get_tunneld_devices
from pymobiledevice3.usbmux import select_devices_by_connection_type
from pymobiledevice3.utils import get_asyncio_loop

USBMUX_OPTION_HELP = 'usbmuxd listener address (in the form of either /path/to/unix/socket OR HOST:PORT'
COLORED_OUTPUT = True
Expand Down Expand Up @@ -220,15 +220,15 @@ def __init__(self, *args, **kwargs):
def rsd(self, ctx, param: str, value: Optional[Tuple[str, int]]) -> Optional[RemoteServiceDiscoveryService]:
if value is not None:
rsd = RemoteServiceDiscoveryService(value)
get_asyncio_loop().run_until_complete(rsd.connect())
asyncio.run(rsd.connect(), debug=True)
self.service_provider = rsd
return self.service_provider

def tunneld(self, ctx, param: str, udid: Optional[str] = None) -> Optional[RemoteServiceDiscoveryService]:
if udid is None:
return

rsds = get_tunneld_devices()
rsds = asyncio.run(async_get_tunneld_devices(), debug=True)
if len(rsds) == 0:
raise NoDeviceConnectedError()

Expand All @@ -247,7 +247,7 @@ def tunneld(self, ctx, param: str, udid: Optional[str] = None) -> Optional[Remot
for rsd in rsds:
if rsd == self.service_provider:
continue
get_asyncio_loop().run_until_complete(rsd.close())
asyncio.run(rsd.close(), debug=True)

return self.service_provider

Expand Down

0 comments on commit e535513

Please sign in to comment.