mirror of
https://github.com/ARM-software/devlib.git
synced 2025-02-25 14:07:50 +00:00
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
This commit is contained in:
parent
1dc1e1364c
commit
89256fd408
devlib/utils
@ -152,6 +152,7 @@ class AdbConnection(object):
|
|||||||
# maintains the count of parallel active connections to a device, so that
|
# maintains the count of parallel active connections to a device, so that
|
||||||
# adb disconnect is not invoked untill all connections are closed
|
# adb disconnect is not invoked untill all connections are closed
|
||||||
active_connections = defaultdict(int)
|
active_connections = defaultdict(int)
|
||||||
|
default_timeout = 10
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@ -168,8 +169,8 @@ class AdbConnection(object):
|
|||||||
else:
|
else:
|
||||||
raise DevlibError("Unknown line ending")
|
raise DevlibError("Unknown line ending")
|
||||||
|
|
||||||
def __init__(self, device=None, timeout=10):
|
def __init__(self, device=None, timeout=None):
|
||||||
self.timeout = timeout
|
self.timeout = timeout if timeout is not None else self.default_timeout
|
||||||
if device is None:
|
if device is None:
|
||||||
device = adb_get_device(timeout=timeout)
|
device = adb_get_device(timeout=timeout)
|
||||||
self.device = device
|
self.device = device
|
||||||
|
@ -127,6 +127,7 @@ class SshConnection(object):
|
|||||||
|
|
||||||
default_password_prompt = '[sudo] password'
|
default_password_prompt = '[sudo] password'
|
||||||
max_cancel_attempts = 5
|
max_cancel_attempts = 5
|
||||||
|
default_timeout=10
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@ -138,7 +139,7 @@ class SshConnection(object):
|
|||||||
password=None,
|
password=None,
|
||||||
keyfile=None,
|
keyfile=None,
|
||||||
port=None,
|
port=None,
|
||||||
timeout=10,
|
timeout=None,
|
||||||
telnet=False,
|
telnet=False,
|
||||||
password_prompt=None,
|
password_prompt=None,
|
||||||
):
|
):
|
||||||
@ -150,6 +151,7 @@ class SshConnection(object):
|
|||||||
self.lock = threading.Lock()
|
self.lock = threading.Lock()
|
||||||
self.password_prompt = password_prompt if password_prompt is not None else self.default_password_prompt
|
self.password_prompt = password_prompt if password_prompt is not None else self.default_password_prompt
|
||||||
logger.debug('Logging in {}@{}'.format(username, host))
|
logger.debug('Logging in {}@{}'.format(username, host))
|
||||||
|
timeout = timeout if timeout is not None else self.default_timeout
|
||||||
self.conn = ssh_get_shell(host, username, password, self.keyfile, port, timeout, telnet)
|
self.conn = ssh_get_shell(host, username, password, self.keyfile, port, timeout, telnet)
|
||||||
|
|
||||||
def push(self, source, dest, timeout=30):
|
def push(self, source, dest, timeout=30):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user