summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Denkowski <mdenkows@sendai.lti.cs.cmu.edu>2013-09-22 22:49:46 -0400
committerMichael Denkowski <mdenkows@sendai.lti.cs.cmu.edu>2013-09-22 22:49:46 -0400
commit26505958e4ab2f865c2a838628af21ae4ad70e01 (patch)
tree1c683d2de810415dbb38ba133d557d18570577f8
parentee384acf34de0d7613a70b81c674d607a3bd782a (diff)
Don't leak open files.
-rw-r--r--realtime/rt/rt.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/realtime/rt/rt.py b/realtime/rt/rt.py
index b1cf19ef..033ed790 100644
--- a/realtime/rt/rt.py
+++ b/realtime/rt/rt.py
@@ -101,7 +101,8 @@ class RealtimeDecoder:
logging.info('Grammar cache hit')
return grammar_file
# Extract and cache
- grammar_file = tempfile.mkstemp(dir=self.tmp, prefix='grammar.')[1]
+ (fid, grammar_file) = tempfile.mkstemp(dir=self.tmp, prefix='grammar.')
+ os.close(fid)
with open(grammar_file, 'w') as output:
for rule in self.extractor.grammar(sentence):
output.write('{}\n'.format(str(rule)))