From d3b42b04698ccdb98b199048b31a470f4bc2924d Mon Sep 17 00:00:00 2001 From: josch Date: Tue, 15 May 2012 12:36:42 +0200 Subject: [PATCH] properly close temporary file handles --- bruteforce3.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bruteforce3.py b/bruteforce3.py index 06c0688..53fdf8b 100644 --- a/bruteforce3.py +++ b/bruteforce3.py @@ -56,7 +56,7 @@ def evaluate_layers_rests(layers, rests, scores, pallet, result_max): packlist = get_packlist_dict(pallet, articles_to_pack) - _, tmp = tempfile.mkstemp() + tmp_fh, tmp = tempfile.mkstemp() dicttoxmlfile(packlist, tmp) # ugly, ugly, ugly, ugly hack - dont copy this... @@ -66,6 +66,7 @@ def evaluate_layers_rests(layers, rests, scores, pallet, result_max): score = libpallet.evaluate(sys.argv[1], tmp, sys.argv[3]) if score >= max(scores+[0]): result_max[0] = dicttoxmlstring(packlist) + os.close(tmp_fh) os.remove(tmp) scores.append(score)