aboutsummaryrefslogtreecommitdiffstats
path: root/examples
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 /examples
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 'examples')
-rw-r--r--examples/addons/commands-paths.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/addons/commands-paths.py b/examples/addons/commands-paths.py
index f37a0fbc..4d9535b9 100644
--- a/examples/addons/commands-paths.py
+++ b/examples/addons/commands-paths.py
@@ -20,9 +20,9 @@ class MyAddon:
for f in flows:
totals[f.request.host] = totals.setdefault(f.request.host, 0) + 1
- fp = open(path, "w+")
- for cnt, dom in sorted([(v, k) for (k, v) in totals.items()]):
- fp.write("%s: %s\n" % (cnt, dom))
+ with open(path, "w+") as fp:
+ for cnt, dom in sorted([(v, k) for (k, v) in totals.items()]):
+ fp.write("%s: %s\n" % (cnt, dom))
ctx.log.alert("done")