Skip to content
Snippets Groups Projects
Commit 6e99148c authored by Kipp Cannon's avatar Kipp Cannon
Browse files

gstlal.inspiral: clean up temp trigger file writing

- use tempfile.NamedTemporaryFile() to remove the need to call os.close() on the file descriptor
- explicitly .unlink() the XML document to help garbage collection
parent bdbc018f
No related branches found
No related tags found
No related merge requests found
......@@ -227,15 +227,15 @@ def parse_bank_files(svd_banks, verbose, snr_threshold = None):
# to close later without a ulimit problem
xmldoc = ligolw.Document()
root = xmldoc.appendChild(ligolw.LIGO_LW())
fobj, fname = tempfile.mkstemp(suffix=".gz")
fname = tempfile.NamedTemporaryFile(suffix = ".gz", delete = False).name
root.appendChild(bank.sngl_inspiral_table)
ligolw_utils.write_filename(xmldoc, fname, gz = True, verbose = verbose)
xmldoc.unlink() # help garbage collector
bank.template_bank_filename = fname
bank.logname = "%sbank%d" % (instrument,n)
banks.setdefault(instrument,[]).append(bank)
if snr_threshold is not None:
bank.snr_threshold = snr_threshold
os.close(fobj) #close the temporary file or else you will have ulimit issues
return banks
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment