1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 11:18:11 +00:00

Different approach to handle no data returned by Dynamips or uBridge hypervisors. Fixes #1289.

This commit is contained in:
grossmj 2018-03-07 19:33:19 +07:00
parent a3a0657502
commit 7c14e21f4a

View File

@ -260,6 +260,8 @@ class DynamipsHypervisor:
# Now retrieve the result # Now retrieve the result
data = [] data = []
buf = '' buf = ''
retries = 0
max_retries = 10
while True: while True:
try: try:
try: try:
@ -276,11 +278,14 @@ class DynamipsHypervisor:
log.warning("Connection reset received while reading Dynamips response: {}".format(e)) log.warning("Connection reset received while reading Dynamips response: {}".format(e))
continue continue
if not chunk: if not chunk:
if self.is_running(): if retries > max_retries:
log.warning("No data returned from {host}:{port}".format(host=self._host, port=self._port))
continue
raise DynamipsError("No data returned from {host}:{port}, Dynamips process running: {run}" raise DynamipsError("No data returned from {host}:{port}, Dynamips process running: {run}"
.format(host=self._host, port=self._port, run=self.is_running())) .format(host=self._host, port=self._port, run=self.is_running()))
else:
retries += 1
yield from asyncio.sleep(0.1)
continue
retries = 0
buf += chunk.decode("utf-8", errors="ignore") buf += chunk.decode("utf-8", errors="ignore")
except OSError as e: except OSError as e:
raise DynamipsError("Could not read response for '{command}' from {host}:{port}: {error}, process running: {run}" raise DynamipsError("Could not read response for '{command}' from {host}:{port}: {error}, process running: {run}"