def __init__(self, name, firstCheckDelay = None):
        Job.__init__(self, name)
        self._serialNum = serialNum()

        self._findContainersJob = None
        self._checkContainersJob = None
        self._pruneContainersJob = None

        if firstCheckDelay is None:
            firstCheckDelay = 60. * 15.
        # divide by two, since the first check just takes length measurements and
        # doesn't check for leaks
        self._nextCheckDelay = firstCheckDelay/2.
        self._checkDelayScale = config.GetFloat('leak-detector-check-delay-scale', 1.5)
        self._pruneTaskPeriod = config.GetFloat('leak-detector-prune-period', 60. * 30.)

        # main dict of id(container)->containerRef
        self._id2ref = {}
        # storage for results of check-container job
        self._index2containerId2len = {}
        self._index2delay = {}

        if config.GetBool('leak-container', 0):
            _createContainerLeak()
        if config.GetBool('leak-tasks', 0):
            _createTaskLeak()

        # don't check our own tables for leaks
        ContainerLeakDetector.addPrivateObj(ContainerLeakDetector.PrivateIds)
        ContainerLeakDetector.addPrivateObj(self.__dict__)

        self.setPriority(Job.Priorities.Min)
        jobMgr.add(self)
Ejemplo n.º 2
0
 def __init__(self,
              name,
              log=True,
              verbose=False,
              fullReport=False,
              findCycles=True,
              threaded=False,
              doneCallback=None,
              autoDestroy=False,
              priority=None,
              safeMode=False,
              delOnly=False,
              collect=True):
     # if autoDestroy is True, GarbageReport will self-destroy after logging
     # if false, caller is responsible for calling destroy()
     # if threaded is True, processing will be performed over multiple frames
     # if collect is False, we assume that the caller just did a collect and the results
     # are still in gc.garbage
     Job.__init__(self, name)
     # stick the arguments onto a ScratchPad so we can delete them all at once
     self._args = ScratchPad(name=name,
                             log=log,
                             verbose=verbose,
                             fullReport=fullReport,
                             findCycles=findCycles,
                             doneCallback=doneCallback,
                             autoDestroy=autoDestroy,
                             safeMode=safeMode,
                             delOnly=delOnly,
                             collect=collect)
     if priority is not None:
         self.setPriority(priority)
     jobMgr.add(self)
     if not threaded:
         jobMgr.finish(self)
 def _pruneObjectRefs(self, task=None):
     self._pruneContainersJob = PruneObjectRefs(
         '%s-pruneObjectRefs' % self.getJobName(), self)
     self.acceptOnce(self._pruneContainersJob.getFinishedEvent(),
                     self._scheduleNextPruning)
     jobMgr.add(self._pruneContainersJob)
     return task.done
 def _checkForLeaks(self, task=None):
     self._index2delay[len(self._index2containerId2len)] = self._nextCheckDelay
     self._checkContainersJob = CheckContainers(
         '%s-checkForLeaks' % self.getJobName(), self, len(self._index2containerId2len))
     self.acceptOnce(self._checkContainersJob.getFinishedEvent(),
                     self._scheduleNextLeakCheck)
     jobMgr.add(self._checkContainersJob)
     return task.done
Ejemplo n.º 5
0
 def __len__(self):
     if self._createJob:
         if self._createJob.isFinished():
             self._createJob.destroy()
             self._createJob = None
     self._createJob = _MessageListenerTypeLeakDetectorCreator(self)
     jobMgr.add(self._createJob)
     # are we leaking listener types?
     return len(self._typeName2detector)
    def run(self):
        # start looking for containers
        self._findContainersJob = FindContainers(
            '%s-findContainers' % self.getJobName(), self)
        jobMgr.add(self._findContainersJob)

        self._scheduleNextLeakCheck()
        self._scheduleNextPruning()

        while True:
            yield Job.Sleep
Ejemplo n.º 7
0
 def __init__(self, name, log=False, limit=None, threaded=False):
     Job.__init__(self, name)
     self._log = log
     self._limit = limit
     # set up our data structures
     self._visitedIds = set()
     self._id2pathStr = {}
     self._id2container = {}
     self._type2id2len = {}
     self._instanceDictIds = set()
     # for breadth-first searching
     self._queue = Queue()
     jobMgr.add(self)
     if not threaded:
         jobMgr.finish(self)
Ejemplo n.º 8
0
 def addTestJob():
     from direct.showbase.JobManagerGlobal import jobMgr
     jobMgr.add(TestJob())
 def __init__(self, name):
     Job.__init__(self, name)
     self.setPriority(Job.Priorities.Normal * 2)
     jobMgr.add(self)
 def getPathsToContainersNamed(self, name, on, doneCallback=None):
     j =  FPTObjsNamed(name, self, on, doneCallback)
     jobMgr.add(j)
     return j
 def getPathsToContainers(self, name, ot, doneCallback=None):
     j =  FPTObjsOfType(name, self, ot, doneCallback)
     jobMgr.add(j)
     return j