[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] Properly handle closure of filedescriptors in runner.py
commit 650529edd0609761302f88a1d9d0a54753249348
Author: Arturo Filastò <art@xxxxxxxxx>
Date: Mon Dec 24 20:27:24 2012 +0100
Properly handle closure of filedescriptors in runner.py
---
ooni/runner.py | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/ooni/runner.py b/ooni/runner.py
index 7787992..228eb61 100644
--- a/ooni/runner.py
+++ b/ooni/runner.py
@@ -276,13 +276,15 @@ def loadResumeFile():
"""
if not config.stateDict:
try:
- config.stateDict = yaml.safe_load(open(config.resume_filename))
+ with open(config.resume_filename) as f:
+ config.stateDict = yaml.safe_load(f)
except:
log.err("Error loading YAML file")
raise InvalidResumeFile
if not config.stateDict:
- yaml.safe_dump(dict(), open(config.resume_filename, 'w+'))
+ with open(config.resume_filename, 'w+') as f:
+ yaml.safe_dump(dict(), f)
config.stateDict = dict()
elif isinstance(config.stateDict, dict):
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits