From 1b301ad5bbe5765b608bf4f8480720065d3343c8 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Tue, 14 Mar 2017 11:41:20 +1300 Subject: [PATCH] Move running() in to .tick() method to make sure it's called consistently --- mitmproxy/master.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mitmproxy/master.py b/mitmproxy/master.py index 88c64a9f1..79747a97d 100644 --- a/mitmproxy/master.py +++ b/mitmproxy/master.py @@ -42,6 +42,7 @@ class Master: self.event_queue = queue.Queue() self.should_exit = threading.Event() self.server = server + self.first_tick = True channel = controller.Channel(self.event_queue, self.should_exit) server.set_channel(channel) @@ -76,20 +77,19 @@ class Master: def run(self): self.start() - running = False try: while not self.should_exit.is_set(): # Don't choose a very small timeout in Python 2: # https://github.com/mitmproxy/mitmproxy/issues/443 # TODO: Lower the timeout value if we move to Python 3. self.tick(0.1) - if not running: - running = True - self.addons.invoke_all_with_context("running") finally: self.shutdown() def tick(self, timeout): + if self.first_tick: + self.first_tick = False + self.addons.invoke_all_with_context("running") with self.handlecontext(): self.addons("tick") changed = False