1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-26 00:38:10 +00:00

Multiple improvements around starting the GNS3 VM

* avoid concurrent start
* proper catching of the TimeOut error

Ref #754
This commit is contained in:
Julien Duponchelle 2016-11-21 09:58:42 +01:00
parent 40af2a35e0
commit 1beae95443
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8

View File

@ -27,6 +27,7 @@ import io
from ..utils import parse_version from ..utils import parse_version
from ..utils.images import scan_for_images, md5sum from ..utils.images import scan_for_images, md5sum
from ..utils.asyncio import locked_coroutine
from ..controller.controller_error import ControllerError from ..controller.controller_error import ControllerError
from ..config import Config from ..config import Config
from ..version import __version__ from ..version import __version__
@ -354,7 +355,7 @@ class Compute:
response = yield from self._run_http_query(method, path, data=data, **kwargs) response = yield from self._run_http_query(method, path, data=data, **kwargs)
return response return response
@asyncio.coroutine @locked_coroutine
def connect(self): def connect(self):
""" """
Check if remote server is accessible Check if remote server is accessible
@ -469,6 +470,8 @@ class Compute:
data = json.dumps(data) data = json.dumps(data)
try: try:
response = yield from self._session().request(method, url, headers=headers, data=data, auth=self._auth, chunked=chunked, timeout=timeout) response = yield from self._session().request(method, url, headers=headers, data=data, auth=self._auth, chunked=chunked, timeout=timeout)
except asyncio.TimeoutError as e:
raise ComputeError("Timeout error when connecting to {}".format(url))
except (aiohttp.errors.ClientOSError, aiohttp.errors.ClientRequestError, aiohttp.ClientResponseError) as e: except (aiohttp.errors.ClientOSError, aiohttp.errors.ClientRequestError, aiohttp.ClientResponseError) as e:
raise ComputeError(str(e)) raise ComputeError(str(e))
body = yield from response.read() body = yield from response.read()