diff options
author | Aldo Cortesi <aldo@corte.si> | 2017-03-14 11:41:20 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@corte.si> | 2017-03-14 11:41:20 +1300 |
commit | 1b301ad5bbe5765b608bf4f8480720065d3343c8 (patch) | |
tree | 8c8f24f119aae9b22832bfa0e6b5c0a397133d17 /mitmproxy/master.py | |
parent | b745428b5c4e89753a83fe228cb5478327eeb540 (diff) | |
download | mitmproxy-1b301ad5bbe5765b608bf4f8480720065d3343c8.tar.gz mitmproxy-1b301ad5bbe5765b608bf4f8480720065d3343c8.tar.bz2 mitmproxy-1b301ad5bbe5765b608bf4f8480720065d3343c8.zip |
Move running() in to .tick() method to make sure it's called consistently
Diffstat (limited to 'mitmproxy/master.py')
-rw-r--r-- | mitmproxy/master.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/mitmproxy/master.py b/mitmproxy/master.py index 88c64a9f..79747a97 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 |