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

StreamThinca: don't hold ref to xmldoc

parent 718b238c
No related branches found
No related tags found
No related merge requests found
......@@ -89,7 +89,6 @@ class SnglInspiral(snglinspiraltable.GSTLALSnglInspiral):
class StreamThinca(object):
def __init__(self, coincidence_threshold, thinca_interval = 50.0, min_instruments = 2, min_log_L = None, sngls_snr_threshold = None):
self._xmldoc = None
self.thinca_interval = thinca_interval # seconds
self.last_coincs = {}
if min_instruments < 1:
......@@ -146,6 +145,17 @@ class StreamThinca(object):
def add_events(self, xmldoc, process_id, events, boundary, seglists, fapfar = None):
"""
NOTE: upon the first invocation of .add_events() some
initialization occurs using xmldoc. no other xmldoc object
may be used on any subsequent invocation until .flush() is
invoked or else the behaviour is undefined. The code used
to have safety checks to monitor for changes to the xmldoc
tree but it was found that that confused the garbage
collector and led to memory leaks, so for now it is left as
an exercise for the calling code to ensure it follows the
rules.
"""
# invalidate the coinc extractor in case all that follows
# is a no-op
self.last_coincs = {}
......@@ -158,9 +168,6 @@ class StreamThinca(object):
# subclass
if self.sngl_inspiral_table is None:
self.sngl_inspiral_table = lsctables.New(lsctables.SnglInspiralTable, lsctables.SnglInspiralTable.get_table(xmldoc).columnnames)
# so we can watch for it changing
assert self._xmldoc is None
self._xmldoc = xmldoc
# How far apart two singles can be and still be
# coincident, including time slide offsets.
offsetvectors = lsctables.TimeSlideTable.get_table(xmldoc).as_dict()
......@@ -218,9 +225,6 @@ class StreamThinca(object):
# have been obtained on this iteration.
#
# safety check
assert xmldoc is self._xmldoc
# check that we've accumulated thinca_interval seconds, and
# that .add_events() has been called with some events since
# the last flush
......@@ -376,12 +380,8 @@ class StreamThinca(object):
# is a no-op.
self.last_coincs = {}
# coincidence. don't bother unless .add_events() has been
# called since the last flush()
if self._xmldoc is not None:
noncoinc_sngls = self.run_coincidence(xmldoc, process_id, segments.infinity(), seglists, fapfar = fapfar)
else:
noncoinc_sngls = []
# coincidence.
noncoinc_sngls = self.run_coincidence(xmldoc, process_id, segments.infinity(), seglists, fapfar = fapfar)
# any event that hasn't been used in a coinc by now will
# never be
......@@ -395,8 +395,5 @@ class StreamThinca(object):
# like a fresh copy of the stream thinca instance
self.last_boundary = -segments.infinity()
# it's now safe to work with a different document
self._xmldoc = None
# return non-coincident sngls
return noncoinc_sngls
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