From 0713724a97ffd0648fd5235095f78f7df9f3f87f Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Wed, 25 Feb 2015 11:42:02 +0100 Subject: [PATCH] Properly handle when client cancel's query --- gns3server/crash_report.py | 6 +++++- gns3server/web/route.py | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gns3server/crash_report.py b/gns3server/crash_report.py index 06d11803..44f96588 100644 --- a/gns3server/crash_report.py +++ b/gns3server/crash_report.py @@ -17,6 +17,7 @@ import raven import json +import asyncio.futures from .version import __version__ from .config import Config @@ -47,7 +48,10 @@ class CrashReport: "url": request.path, "data": request.json, }) - self._client.captureException() + try: + self._client.captureException() + except asyncio.futures.TimeoutError: + pass # We don't care if we can send the bug report @classmethod def instance(cls): diff --git a/gns3server/web/route.py b/gns3server/web/route.py index bf30e35f..f6f9407f 100644 --- a/gns3server/web/route.py +++ b/gns3server/web/route.py @@ -136,6 +136,11 @@ class Route(object): response = Response(route=route) response.set_status(409) response.json({"message": str(e), "status": 409}) + except asyncio.futures.CancelledError as e: + log.error("Request canceled") + response = Response(route=route) + response.set_status(408) + response.json({"message": "Request canceled", "status": 408}) except Exception as e: log.error("Uncaught exception detected: {type}".format(type=type(e)), exc_info=1) response = Response(route=route)