Skip to content
This repository has been archived by the owner on Feb 20, 2018. It is now read-only.

Commit

Permalink
Sleep in wait_for_generator and refactor ping_vm in clone
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Zubov authored and Stanislav Zubov committed Oct 23, 2015
1 parent d707bd1 commit 0bae841
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,11 @@ def wait_for(condition, timeout=5):

return condition()


def generator_wait_for(condition, timeout=5):
start = time.time()
while not condition() and time.time() - start < timeout:
time.sleep(0.1)
yield None

yield condition()
Expand Down
3 changes: 2 additions & 1 deletion vmpool/clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ def rebuild(self):

def ping_vm(self):
ports = [config.SELENIUM_PORT, config.VMMASTER_AGENT_PORT]
result = [False, False]
timeout = config.PING_TIMEOUT
start = time.time()

log.info("Starting ping vm {clone}: {ip}:{port}".format(
clone=self.name, ip=self.ip, port=ports))
_ping = partial(network_utils.ping, self.ip)
Expand All @@ -72,7 +74,6 @@ def ping_vm(self):
break
time.sleep(0.1)

result = map(_ping, ports)
if not all(result):
fails = [port for port, res in zip(ports, result) if res is False]
log.info("Failed ping for {clone} with {ip}:{ports}".format(
Expand Down

0 comments on commit 0bae841

Please sign in to comment.