diff options
author | Minghao Li <minghaoli@google.com> | 2024-02-07 10:39:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-06 18:39:46 -0800 |
commit | f7eb2a0a5410fa7014f51b439fe72b1d4c1433cd (patch) | |
tree | 17c151cf8b39e77fa01e100d83f28d4410e5409c | |
parent | 28be0fdba146f2a180e567126749b34bde9ff8cf (diff) | |
download | mobly-f7eb2a0a5410fa7014f51b439fe72b1d4c1433cd.tar.gz |
Mark `utils.get_available_host_port` deprecated (#907)
Getting host port then applying it is inherently unreliable.
Letting the OS handle it is better.
-rw-r--r-- | mobly/utils.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/mobly/utils.py b/mobly/utils.py index 4d5dfc6..02125ed 100644 --- a/mobly/utils.py +++ b/mobly/utils.py @@ -596,6 +596,8 @@ def wait_for_standing_subprocess(proc, timeout=None): def get_available_host_port(): """Gets a host port number available for adb forward. + DEPRECATED: This method is unreliable. Pass `tcp:0` to adb forward instead. + Returns: An integer representing a port number on the host available for adb forward. @@ -603,6 +605,11 @@ def get_available_host_port(): Raises: Error: when no port is found after MAX_PORT_ALLOCATION_RETRY times. """ + logging.warning( + 'The method mobly.utils.get_available_host_port is deprecated because it ' + 'is unreliable. Pass "tcp:0" to adb forward instead.' + ) + # Only import adb module if needed. from mobly.controllers.android_device_lib import adb |