diff options
author | Aldo Cortesi <aldo@corte.si> | 2018-05-01 11:31:42 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@corte.si> | 2018-05-02 08:50:17 +1200 |
commit | 204726349df6f24c6a542902974e1cca7e20ce3a (patch) | |
tree | 19e4fb892baed4db9789d59d8a1a865af3878015 | |
parent | 00d790fe84ec860f1de46330cda0e73884e07e2f (diff) | |
download | mitmproxy-204726349df6f24c6a542902974e1cca7e20ce3a.tar.gz mitmproxy-204726349df6f24c6a542902974e1cca7e20ce3a.tar.bz2 mitmproxy-204726349df6f24c6a542902974e1cca7e20ce3a.zip |
client replay: replaying flows in-flight should be added to count()
-rw-r--r-- | mitmproxy/addons/clientplayback.py | 7 | ||||
-rw-r--r-- | mitmproxy/tools/console/commandexecutor.py | 2 |
2 files changed, 7 insertions, 2 deletions
diff --git a/mitmproxy/addons/clientplayback.py b/mitmproxy/addons/clientplayback.py index 11d2453b..e9fbadce 100644 --- a/mitmproxy/addons/clientplayback.py +++ b/mitmproxy/addons/clientplayback.py @@ -1,4 +1,5 @@ import queue +import threading import typing from mitmproxy import log @@ -30,12 +31,15 @@ class RequestReplayThread(basethread.BaseThread): self.options = opts self.channel = channel self.queue = queue + self.inflight = threading.Event() super().__init__("RequestReplayThread") def run(self): while True: f = self.queue.get() + self.inflight.set() self.replay(f) + self.inflight.clear() def replay(self, f): # pragma: no cover f.live = True @@ -163,7 +167,8 @@ class ClientPlayback: """ Approximate number of flows queued for replay. """ - return self.q.qsize() + inflight = 1 if self.thread and self.thread.inflight.is_set() else 0 + return self.q.qsize() + inflight @command.command("replay.client.stop") def stop_replay(self) -> None: diff --git a/mitmproxy/tools/console/commandexecutor.py b/mitmproxy/tools/console/commandexecutor.py index 26f92238..3db03d3e 100644 --- a/mitmproxy/tools/console/commandexecutor.py +++ b/mitmproxy/tools/console/commandexecutor.py @@ -14,7 +14,7 @@ class CommandExecutor: def __call__(self, cmd): if cmd.strip(): try: - ret = self.master.commands.call(cmd) + ret = self.master.commands.execute(cmd) except exceptions.CommandError as v: signals.status_message.send(message=str(v)) else: |