Fixes connect call failed for Dynamips hypervisor #78.

This commit is contained in:
grossmj 2015-03-01 14:25:09 -07:00
parent 7223005acd
commit 518b037d54

View File

@ -73,12 +73,20 @@ class DynamipsHypervisor:
else: else:
host = self._host host = self._host
try: tries = 3
self._reader, self._writer = yield from asyncio.wait_for(asyncio.open_connection(host, self._port), timeout=self._timeout) while tries > 0:
except OSError as e: try:
raise DynamipsError("Could not connect to hypervisor {}:{} {}".format(host, self._port, e)) self._reader, self._writer = yield from asyncio.wait_for(asyncio.open_connection(host, self._port), timeout=self._timeout)
except asyncio.TimeoutError: break
raise DynamipsError("Timeout error while connecting to hypervisor {}:{}".format(host, self._port)) except OSError as e:
if tries:
tries -= 1
log.warn("Could not connect to hypervisor {}:{} {}, retrying...".format(host, self._port, e))
yield from asyncio.sleep(0.1)
continue
raise DynamipsError("Could not connect to hypervisor {}:{} {}".format(host, self._port, e))
except asyncio.TimeoutError:
raise DynamipsError("Timeout error while connecting to hypervisor {}:{}".format(host, self._port))
try: try:
version = yield from self.send("hypervisor version") version = yield from self.send("hypervisor version")