connetion: fixing None timeout issue
Connection objects set timeout to a default value in case a timeout is
not specified. However, Target defaults timeout to None and passes that
to connection, overridng the default.
This commit ensures that default timeout remains set if calling code
specified timemout as None.
Fix for issue
https://github.com/ARM-software/devlib/issues/34
diff --git a/devlib/utils/android.py b/devlib/utils/android.py
index 66f6f4a..0444b67 100644
--- a/devlib/utils/android.py
+++ b/devlib/utils/android.py
@@ -152,6 +152,7 @@
# maintains the count of parallel active connections to a device, so that
# adb disconnect is not invoked untill all connections are closed
active_connections = defaultdict(int)
+ default_timeout = 10
@property
def name(self):
@@ -168,8 +169,8 @@
else:
raise DevlibError("Unknown line ending")
- def __init__(self, device=None, timeout=10):
- self.timeout = timeout
+ def __init__(self, device=None, timeout=None):
+ self.timeout = timeout if timeout is not None else self.default_timeout
if device is None:
device = adb_get_device(timeout=timeout)
self.device = device