aboutsummaryrefslogtreecommitdiffstats
path: root/test/bench
diff options
context:
space:
mode:
authorMickaël Schoentgen <contact@tiger-222.fr>2019-01-06 15:06:30 +0100
committerMickaël Schoentgen <contact@tiger-222.fr>2019-01-06 15:06:30 +0100
commitc03b07930ccf41b696ae02c363d116ba602313d3 (patch)
tree66cb0f48d6de421a1f93f196716da1db81990eaa /test/bench
parent889987aa0a7f4852758ed09f70fe5d30f733a6d3 (diff)
downloadmitmproxy-c03b07930ccf41b696ae02c363d116ba602313d3.tar.gz
mitmproxy-c03b07930ccf41b696ae02c363d116ba602313d3.tar.bz2
mitmproxy-c03b07930ccf41b696ae02c363d116ba602313d3.zip
Fix ResourceWarning: unclosed file, prevent resource leaks
Signed-off-by: Mickaël Schoentgen <contact@tiger-222.fr>
Diffstat (limited to 'test/bench')
-rw-r--r--test/bench/benchmark.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/test/bench/benchmark.py b/test/bench/benchmark.py
index 84ec6005..076ad6c9 100644
--- a/test/bench/benchmark.py
+++ b/test/bench/benchmark.py
@@ -31,7 +31,8 @@ class Benchmark:
stdout=asyncio.subprocess.PIPE
)
stdout, _ = await traf.communicate()
- open(ctx.options.benchmark_save_path + ".bench", mode="wb").write(stdout)
+ with open(ctx.options.benchmark_save_path + ".bench", mode="wb") as f:
+ f.write(stdout)
ctx.log.error("Proxy saw %s requests, %s responses" % (self.reqs, self.resps))
ctx.log.error(stdout.decode("ascii"))
backend.kill()