From 6135e16482b5962d1b5019666b0db1cbb2881333 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Fri, 6 Nov 2015 11:35:54 +1300 Subject: [PATCH] Catch and ignore thread errors on exit Keyboard interrupts bugger up Queues in some way, which causes a traceback on exit in many of our tools. The issue seems easiest to reproduce with binary builds on OSX. --- libmproxy/main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libmproxy/main.py b/libmproxy/main.py index 23cb487c6..3c908ed9f 100644 --- a/libmproxy/main.py +++ b/libmproxy/main.py @@ -2,6 +2,7 @@ from __future__ import print_function, absolute_import import os import signal import sys +import thread from netlib.version_check import check_pyopenssl_version, check_mitmproxy_version from . import version, cmdline from .exceptions import ServerException @@ -62,7 +63,7 @@ def mitmproxy(args=None): # pragma: nocover m = console.ConsoleMaster(server, console_options) try: m.run() - except KeyboardInterrupt: + except (KeyboardInterrupt, thread.error): pass @@ -97,7 +98,7 @@ def mitmdump(args=None): # pragma: nocover except dump.DumpError as e: print("mitmdump: %s" % e, file=sys.stderr) sys.exit(1) - except KeyboardInterrupt: + except (KeyboardInterrupt, thread.error): pass @@ -125,5 +126,5 @@ def mitmweb(args=None): # pragma: nocover m = web.WebMaster(server, web_options) try: m.run() - except KeyboardInterrupt: + except (KeyboardInterrupt, thread.error): pass