aboutsummaryrefslogtreecommitdiffstats
path: root/test/bench/benchmark.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2019-01-06 17:43:47 +0100
committerGitHub <noreply@github.com>2019-01-06 17:43:47 +0100
commit82bc8c7ca2b946e7f022b92ab16ced2924feb284 (patch)
treec65361f74b829edf9181752c4f7cec9e9374a0e3 /test/bench/benchmark.py
parent4f270b5506fe2b1314ee277d9f7c93763cb2d8e5 (diff)
parentc03b07930ccf41b696ae02c363d116ba602313d3 (diff)
downloadmitmproxy-82bc8c7ca2b946e7f022b92ab16ced2924feb284.tar.gz
mitmproxy-82bc8c7ca2b946e7f022b92ab16ced2924feb284.tar.bz2
mitmproxy-82bc8c7ca2b946e7f022b92ab16ced2924feb284.zip
Merge pull request #3444 from BoboTiG/fix-resource-leaks
Fix ResourceWarning: unclosed file, prevent resource leaks
Diffstat (limited to 'test/bench/benchmark.py')
-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()