提交 046a831d 编写于 作者: L Lukáš Doktor

avocado.core.remoter: Avoid repeating of the remote command

Currently the remote loop is missing "break" so it resends the same
command until the timeout is reached.

While working on this I recreated the loop so it supports None timeout,
which is required for some operations.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 82b09c6d
......@@ -87,16 +87,30 @@ class Remote(object):
"""
result = process.CmdResult()
start_time = time.time()
end_time = time.time() + timeout
end_time = time.time() + (timeout or 0) # Support timeout=None
# Fabric sometimes returns NetworkError even when timeout not reached
while time.time() < end_time:
fabric_result = None
fabric_exception = None
while True:
try:
fabric_result = fabric.operations.run(command=command,
quiet=self.quiet,
warn_only=True,
timeout=timeout)
except fabric.network.NetworkError:
break
except fabric.network.NetworkError, details:
fabric_exception = details
timeout = end_time - time.time()
if time.time() < end_time:
break
if fabric_result is None:
if fabric_exception is not None:
raise fabric_exception # it's not None pylint: disable=E0702
else:
raise fabric.network.NetworkError("Remote execution of '%s'"
"failed without any "
"exception. This should not "
"happen." % command)
end_time = time.time()
duration = end_time - start_time
result.command = command
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册