From c03b07930ccf41b696ae02c363d116ba602313d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Schoentgen?= Date: Sun, 6 Jan 2019 15:06:30 +0100 Subject: Fix ResourceWarning: unclosed file, prevent resource leaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mickaƫl Schoentgen --- test/bench/benchmark.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test/bench/benchmark.py') 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() -- cgit v1.2.3