1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-26 00:38:10 +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 response.content_length = None
try: 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: except FileNotFoundError:
raise aiohttp.web.HTTPNotFound() raise aiohttp.web.HTTPNotFound()
except PermissionError: except PermissionError:
raise aiohttp.web.HTTPForbidden 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)