From fc6b6b5e6361860d4d25ca3ac13caa0aa35bcace Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Thu, 27 Jul 2017 15:32:46 +0200 Subject: [PATCH] Fix race condition in startup of capture Fix https://github.com/GNS3/gns3-gui/issues/2111 --- gns3server/handlers/api/controller/link_handler.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gns3server/handlers/api/controller/link_handler.py b/gns3server/handlers/api/controller/link_handler.py index 6ec5e466..96d89cfc 100644 --- a/gns3server/handlers/api/controller/link_handler.py +++ b/gns3server/handlers/api/controller/link_handler.py @@ -15,6 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +import os import asyncio import aiohttp @@ -196,9 +197,12 @@ class LinkHandler: project = yield from Controller.instance().get_loaded_project(request.match_info["project_id"]) link = project.get_link(request.match_info["link_id"]) - if link.capture_file_path is None: + while link.capture_file_path is None: raise aiohttp.web.HTTPNotFound(text="pcap file not found") + while not os.path.isfile(link.capture_file_path): + yield from asyncio.sleep(0.5) + try: with open(link.capture_file_path, "rb") as f: