mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 17:28:08 +00:00
Timeout for stream file.
This commit is contained in:
parent
34fcbd68f3
commit
45edc40948
@ -337,12 +337,13 @@ class Compute:
|
||||
return response
|
||||
|
||||
@asyncio.coroutine
|
||||
def stream_file(self, project, path):
|
||||
def stream_file(self, project, path, timeout=None):
|
||||
"""
|
||||
Read file of a project and stream it
|
||||
|
||||
:param project: A project object
|
||||
:param path: The path of the file in the project
|
||||
:param timeout: timeout
|
||||
:returns: A file stream
|
||||
"""
|
||||
|
||||
@ -361,7 +362,7 @@ class Compute:
|
||||
self._response.close()
|
||||
|
||||
url = self._getUrl("/projects/{}/stream/{}".format(project.id, path))
|
||||
response = yield from self._session().request("GET", url, auth=self._auth, timeout=None)
|
||||
response = yield from self._session().request("GET", url, auth=self._auth, timeout=timeout)
|
||||
if response.status == 404:
|
||||
raise aiohttp.web.HTTPNotFound(text="{} not found on compute".format(path))
|
||||
elif response.status == 403:
|
||||
|
@ -295,8 +295,8 @@ def test_streamFile(project, async_run, compute):
|
||||
response = MagicMock()
|
||||
response.status = 200
|
||||
with asyncio_patch("aiohttp.ClientSession.request", return_value=response) as mock:
|
||||
async_run(compute.stream_file(project, "test/titi"))
|
||||
mock.assert_called_with("GET", "https://example.com:84/v2/compute/projects/{}/stream/test/titi".format(project.id), auth=None, timeout=None)
|
||||
async_run(compute.stream_file(project, "test/titi", timeout=120))
|
||||
mock.assert_called_with("GET", "https://example.com:84/v2/compute/projects/{}/stream/test/titi".format(project.id), auth=None, timeout=120)
|
||||
|
||||
|
||||
def test_downloadFile(project, async_run, compute):
|
||||
|
Loading…
Reference in New Issue
Block a user