Skip to content

Commit

Permalink
Merge pull request #85 from magni5/master
Browse files Browse the repository at this point in the history
immediately free up file handle fo re-use
  • Loading branch information
quaquel authored Feb 7, 2024
2 parents 08d8e88 + 6853b01 commit 16daae4
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 16daae4

Please sign in to comment.