def _wait_for_ssh(queue, ssh, command, timeout=1, attempts=40):
"""Wait until a successful connection to the ssh endpoint can be made."""
try:
host, port = queue.get(timeout=timeout * attempts)
except g_queue.Empty:
cli.bad_exit("No SSH endpoint found.")
for _ in six.moves.range(attempts):
_LOGGER.debug('Checking SSH endpoint %s:%s', host, port)
if checkout.connect(host, port):
run_ssh(host, port, ssh, list(command))
break # if run_ssh doesn't end with os.execvp()...
try:
host, port = queue.get(timeout=timeout)
queue.task_done()
except g_queue.Empty:
pass
# Either all the connection attempts failed or we're after run_ssh
# (not resulting in os.execvp) so let's "clear the queue" so the thread
# can join
queue.task_done()
评论列表
文章目录