aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2017-08-22 00:31:00 +0200
committerGitHub <noreply@github.com>2017-08-22 00:31:00 +0200
commit7e154171bffbe30c990dd4a522bc65a3a72f2975 (patch)
treebbdf8c0841dbd8a0f74fb77d9eb5caf8cabac60d
parent194883fc6a57b7646a0c045003152c270362dcea (diff)
parentca3e98640c2344da356700635c8d84be1606b411 (diff)
downloadmitmproxy-7e154171bffbe30c990dd4a522bc65a3a72f2975.tar.gz
mitmproxy-7e154171bffbe30c990dd4a522bc65a3a72f2975.tar.bz2
mitmproxy-7e154171bffbe30c990dd4a522bc65a3a72f2975.zip
Merge pull request #2539 from mhils/fix-mitmweb-shutdown
Fix mitmweb master shutdown, tests++
-rw-r--r--mitmproxy/tools/web/master.py5
-rw-r--r--test/mitmproxy/data/addonscripts/shutdown.py5
-rw-r--r--test/mitmproxy/tools/test_main.py19
3 files changed, 28 insertions, 1 deletions
diff --git a/mitmproxy/tools/web/master.py b/mitmproxy/tools/web/master.py
index 3967bafe..694ee2f7 100644
--- a/mitmproxy/tools/web/master.py
+++ b/mitmproxy/tools/web/master.py
@@ -12,7 +12,6 @@ from mitmproxy.addons import readfile
from mitmproxy.addons import termlog
from mitmproxy.addons import view
from mitmproxy.addons import termstatus
-from mitmproxy.options import Options # noqa
from mitmproxy.tools.web import app, webaddons, static_viewer
@@ -130,6 +129,10 @@ class WebMaster(master.Master):
except KeyboardInterrupt:
self.shutdown()
+ def shutdown(self):
+ tornado.ioloop.IOLoop.instance().stop()
+ super().shutdown()
+
def open_browser(url: str) -> bool:
"""
diff --git a/test/mitmproxy/data/addonscripts/shutdown.py b/test/mitmproxy/data/addonscripts/shutdown.py
new file mode 100644
index 00000000..51a99b5c
--- /dev/null
+++ b/test/mitmproxy/data/addonscripts/shutdown.py
@@ -0,0 +1,5 @@
+from mitmproxy import ctx
+
+
+def running():
+ ctx.master.shutdown()
diff --git a/test/mitmproxy/tools/test_main.py b/test/mitmproxy/tools/test_main.py
new file mode 100644
index 00000000..88e2fe86
--- /dev/null
+++ b/test/mitmproxy/tools/test_main.py
@@ -0,0 +1,19 @@
+from mitmproxy.test import tutils
+from mitmproxy.tools import main
+
+shutdown_script = tutils.test_data.path("mitmproxy/data/addonscripts/shutdown.py")
+
+
+def test_mitmweb():
+ main.mitmweb([
+ "--no-web-open-browser",
+ "-q",
+ "-s", shutdown_script
+ ])
+
+
+def test_mitmdump():
+ main.mitmdump([
+ "-q",
+ "-s", shutdown_script
+ ])