Skip to content

Commit

Permalink
immediately free up file handle fo re-use
Browse files Browse the repository at this point in the history
  • Loading branch information
magni5 committed Feb 2, 2024
1 parent c2c910e commit 6853b01
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/pynetlogo/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,10 +509,9 @@ def repeat_report(self, netlogo_reporter, reps, go="go", include_t0=True):
# TODO issue #55
commands = []
fns = {}
fhs = []
for variable in cols:
fh, fn = tempfile.mkstemp(suffix=".txt", dir=tempfolder)
fhs.append(fh)
os.close(fh) #immediately free up file handle for re-use
fns[variable] = fn
fn = '"{}"'.format(fn)
fn = fn.replace(os.sep, "/")
Expand Down Expand Up @@ -555,9 +554,6 @@ def repeat_report(self, netlogo_reporter, reps, go="go", include_t0=True):
results[key] = result

# cleanup temp files and folders
for fh in fhs:
os.close(fh) #free up file handle for re-use

for key, value in fns.items():
os.remove(value) #delete file by name

Expand Down

0 comments on commit 6853b01

Please sign in to comment.