diff options
author | Aldo Cortesi <aldo@corte.si> | 2018-05-08 11:23:52 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2018-05-08 14:26:41 +1200 |
commit | af1a4ffdcd4c98afefd4228bbc2bc276cfd8436f (patch) | |
tree | dacb5e2dae27aabb550b93b181cac0197072707e /mitmproxy/addonmanager.py | |
parent | 717fbaa99076545d11f554187759005dce1aa67b (diff) | |
download | mitmproxy-af1a4ffdcd4c98afefd4228bbc2bc276cfd8436f.tar.gz mitmproxy-af1a4ffdcd4c98afefd4228bbc2bc276cfd8436f.tar.bz2 mitmproxy-af1a4ffdcd4c98afefd4228bbc2bc276cfd8436f.zip |
Ditch the addon stdout wrapper
This results in a 30% improvement in our core request throughput.
Fixes #3102
Diffstat (limited to 'mitmproxy/addonmanager.py')
-rw-r--r-- | mitmproxy/addonmanager.py | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/mitmproxy/addonmanager.py b/mitmproxy/addonmanager.py index 64c957ba..0b559293 100644 --- a/mitmproxy/addonmanager.py +++ b/mitmproxy/addonmanager.py @@ -36,25 +36,10 @@ def cut_traceback(tb, func_name): return tb or tb_orig -class StreamLog: - def __init__(self, lg): - self.log = lg - - def write(self, buf): - if buf.strip(): - self.log(buf) - - def flush(self): # pragma: no cover - # Click uses flush sometimes, so we dummy it up - pass - - @contextlib.contextmanager def safecall(): - stdout_replacement = StreamLog(lambda message: ctx.log.warn(message)) try: - with contextlib.redirect_stdout(stdout_replacement): - yield + yield except (exceptions.AddonHalt, exceptions.OptionsError): raise except Exception as e: |