diff --git a/timeseriesviewer/utils.py b/timeseriesviewer/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..fd0fca056eeb6ae11003ac5e4b329680909b3b1d --- /dev/null +++ b/timeseriesviewer/utils.py @@ -0,0 +1,15 @@ + + +from collections import defaultdict +import weakref +class KeepRefs(object): + __refs__ = defaultdict(list) + def __init__(self): + self.__refs__[self.__class__].append(weakref.ref(self)) + + @classmethod + def instances(cls): + for inst_ref in cls.__refs__[cls]: + inst = inst_ref() + if inst is not None: + yield inst \ No newline at end of file