mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Handle asyncio timeouts. Ref #1307.
This commit is contained in:
1 parent
a56d5b453f
commit
305fe2e817
6 files changed
+40
-21
No files matched your search
@@ -409,8 +409,6 @@ class NodeHandler:
|
||||
|
||||
node_type = node.node_type
|
||||
path = "/project-files/{}/{}/{}".format(node_type, node.id, path)
|
||||
|
||||
data = yield from request.content.read()
|
||||
|
||||
data = yield from request.content.read() #FIXME: are we handling timeout or large files correctly?
|
||||
yield from node.compute.http_query("POST", "/projects/{project_id}/files{path}".format(project_id=project.id, path=path), data=data, timeout=None, raw=True)
|
||||
response.set_status(201)
|
||||
@@ -335,10 +335,10 @@ class ProjectHandler:
|
||||
try:
|
||||
with tempfile.SpooledTemporaryFile(max_size=10000) as temp:
|
||||
while True:
|
||||
packet = yield from request.content.read(1024)
|
||||
if not packet:
|
||||
chunk = yield from request.content.read(1024)
|
||||
if not chunk:
|
||||
break
|
||||
temp.write(packet)
|
||||
temp.write(chunk)
|
||||
project = yield from import_project(controller, request.match_info["project_id"], temp, location=path, name=name)
|
||||
except OSError as e:
|
||||
raise aiohttp.web.HTTPInternalServerError(text="Could not import the project: {}".format(e))
|
||||
@@ -448,10 +448,13 @@ class ProjectHandler:
|
||||
try:
|
||||
with open(path, 'wb+') as f:
|
||||
while True:
|
||||
packet = yield from request.content.read(1024)
|
||||
if not packet:
|
||||
try:
|
||||
chunk = yield from request.content.read(1024)
|
||||
except asyncio.TimeoutError:
|
||||
raise aiohttp.web.HTTPRequestTimeout(text="Timeout when writing to file '{}'".format(path))
|
||||
if not chunk:
|
||||
break
|
||||
f.write(packet)
|
||||
f.write(chunk)
|
||||
except FileNotFoundError:
|
||||
raise aiohttp.web.HTTPNotFound()
|
||||
except PermissionError:
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
import os
|
||||
import aiohttp
|
||||
import asyncio
|
||||
|
||||
from gns3server.web.route import Route
|
||||
from gns3server.controller import Controller
|
||||
|
||||
@@ -66,10 +68,13 @@ class SymbolHandler:
|
||||
try:
|
||||
with open(path, 'wb') as f:
|
||||
while True:
|
||||
packet = yield from request.content.read(1024)
|
||||
if not packet:
|
||||
try:
|
||||
chunk = yield from request.content.read(1024)
|
||||
except asyncio.TimeoutError:
|
||||
raise aiohttp.web.HTTPRequestTimeout(text="Timeout when writing to symbol '{}'".format(path))
|
||||
if not chunk:
|
||||
break
|
||||
f.write(packet)
|
||||
f.write(chunk)
|
||||
except OSError as e:
|
||||
raise aiohttp.web.HTTPConflict(text="Could not write symbol file '{}': {}".format(path, e))
|
||||
# Reset the symbol list
|
||||
|
||||
Reference in new issue
Block a user