7 from collections
import namedtuple
9 from DQUtils.db
import Databases, fetch_iovs
10 from DQUtils.quick_retrieve
import browse_coracool
15 os.environ[
'CLING_STANDARD_PCH'] =
'none'
16 from PyCool
import cool
18 folder_path =
"/SCT/DAQ/Configuration/Module"
20 database = Databases.get_instance(
"COOLONL_SCT/COMP200")
21 folder = database.getFolder(folder_path)
22 since, until = 1221973544491128285, 1221995264779751560
27 Read the timestamps of all luminosity blocks between
28 the run-lumi IoV (since, until)
30 timestamps =
fetch_iovs(
"COOLONL_TRIGGER/COMP200::/TRIGGER/LUMI/LBLB", since, until,
31 with_channel=
False, what=
"all")
32 return timestamps[0].StartTime, timestamps[-1].EndTime, timestamps
36 if "<coracool>" not in folder.description():
37 print(f
"{folder.fullPath()} is not a coracool folder")
40 variables = [
"group",
"id"]
42 record = namedtuple(
"coracool_record",
"since until channel elements")
43 element = namedtuple(
"element",
" ".
join(variables))
48 cool.ChannelSelection(),
"", variables, record, element)
50 elapsed = time()-start
51 print(
"Took %.2f to browse_coracool" % elapsed)
55 bad = [x
for x
in objects
if any(el.group == -1
for el
in x.elements)]
61 record = namedtuple(
"coracool_record",
"since until channel elements")
62 element = namedtuple(
"element",
"group id")
74 before_objects =
set(
id(x)
for x
in gc.get_objects())
77 try:
raise RuntimeError
78 except Exception:
pass
80 print(
"Objects alive before call:", len(gc.get_objects()))
84 cool.ChannelSelection(),
"", [
"group",
"id"],
87 except Exception
as e:
88 print(
"Caught exception ", e)
91 elapsed = time() - start
92 print(
"Took %.3f to browse folder" % elapsed)
94 assert objects
is not None,
'Null return from browse_coracool'
97 print(
"Result length =", len(objects))
98 print(
"Result index 0 length =", len(objects[0]))
99 print(
"Result index 0 =", objects[0])
103 print(
"Objects alive before cleanup:", len(gc.get_objects()))
107 print(
"Objects alive after:", len(gc.get_objects()))
109 after_objects = gc.get_objects()
111 new_objects =
set(
id(x)
for x
in after_objects) - before_objects
114 new_objects = [x
for x
in after_objects
if id(x)
in new_objects
and x != before_objects
and x != new_objects]
116 assert new_objects == [],
'Lingering objects after garbage collection'
119 if __name__ ==
"__main__":