From f0f901a15dd31d6933c18d54b5c9958dc77e9db8 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Mon, 24 Aug 2015 19:57:59 +0200 Subject: [PATCH] Should solve the BufferError by avoiding using thread Fix #293 --- gns3server/handlers/api/project_handler.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/gns3server/handlers/api/project_handler.py b/gns3server/handlers/api/project_handler.py index d2c80a12..0e00ffb8 100644 --- a/gns3server/handlers/api/project_handler.py +++ b/gns3server/handlers/api/project_handler.py @@ -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)