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

Should solve the BufferError by avoiding using thread

Fix #293
This commit is contained in:
Julien Duponchelle 2015-08-24 19:57:59 +02:00
parent 34e64fe5d8
commit f0f901a15d

View File

@ -272,19 +272,15 @@ class ProjectHandler:
response.content_length = None
try:
yield from wait_run_in_executor(ProjectHandler._read_file, path, request, response)
with open(path, "rb") as f:
response.start(request)
while True:
data = f.read(4096)
if not data:
break
yield from response.write(data)
except FileNotFoundError:
raise aiohttp.web.HTTPNotFound()
except PermissionError:
raise aiohttp.web.HTTPForbidden
@staticmethod
def _read_file(path, request, response):
with open(path, "rb") as f:
response.start(request)
while True:
data = f.read(4096)
if not data:
break
response.write(data)