[tor-commits] [ooni-probe/master] Properly handle closure of filedescriptors in runner.py
art at torproject.org
art at torproject.org
Wed Dec 26 16:34:39 UTC 2012
commit 650529edd0609761302f88a1d9d0a54753249348
Author: Arturo Filastò <art at fuffa.org>
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):
More information about the tor-commits
mailing list