aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinghao Li <minghaoli@google.com>2024-02-07 10:39:46 +0800
committerGitHub <noreply@github.com>2024-02-06 18:39:46 -0800
commitf7eb2a0a5410fa7014f51b439fe72b1d4c1433cd (patch)
tree17c151cf8b39e77fa01e100d83f28d4410e5409c
parent28be0fdba146f2a180e567126749b34bde9ff8cf (diff)
downloadmobly-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.py7
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