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)
def checkForGarbageLeaks(): gc.collect() numGarbage = len(gc.garbage) if numGarbage > 0 and config.GetBool('auto-garbage-logging', 0): if numGarbage != _CFGLGlobals.LastNumGarbage: print("") gr = GarbageReport('found garbage', threaded=False, collect=False) print("") _CFGLGlobals.LastNumGarbage = numGarbage _CFGLGlobals.LastNumCycles = gr.getNumCycles() messenger.send(GarbageCycleCountAnnounceEvent, [gr.getDesc2numDict()]) gr.destroy() notify = directNotify.newCategory("GarbageDetect") if config.GetBool('allow-garbage-cycles', 1): func = notify.warning else: func = notify.error func('%s garbage cycles found, see info above' % _CFGLGlobals.LastNumCycles) return numGarbage
def __init__(self): if DConfig.GetBool('textures-power-2', 1): # This is a workaround, if ^ is enabled, the game would only render in the bottom left corner of the window. self.notify.warning( "Cannot be initialized with texture-power-2 config enabled.") return """ The FilterManager constructor requires you to provide a window which is rendering a scene, and the camera which is used by that window to render the scene. These are henceforth called the 'original window' and the 'original camera.' At the very moment ShaderManager only supports postprocessing shaders, which may be the reason why 2d gui is wonky w/ shaders. It seems that FilterManager is used for post processing shaders...? """ self.manager = FilterManager(base.win, base.cam) # self.manager2d = None self.manager2d = FilterManager(base.win, base.cam2d) self.notify.info("Initialized ShaderManager")
from . import DistributedSmoothNodeBase from direct.task.Task import cont from direct.showbase import DConfig as config # This number defines our tolerance for out-of-sync telemetry packets. # If a packet appears to have originated from more than MaxFuture # seconds in the future, assume we're out of sync with the other # avatar and suggest a resync for both. MaxFuture = config.GetFloat("smooth-max-future", 0.2) # How frequently can we suggest a resynchronize with another client? MinSuggestResync = config.GetFloat("smooth-min-suggest-resync", 15) # These flags indicate whether global smoothing and/or prediction is # allowed or disallowed. EnableSmoothing = config.GetBool("smooth-enable-smoothing", 1) EnablePrediction = config.GetBool("smooth-enable-prediction", 1) # These values represent the amount of time, in seconds, to delay the # apparent position of other avatars, when non-predictive and # predictive smoothing is in effect, respectively. This is in # addition to the automatic delay of the observed average latency from # each avatar, which is intended to compensate for relative clock # skew. Lag = config.GetDouble("smooth-lag", 0.2) PredictionLag = config.GetDouble("smooth-prediction-lag", 0.0) GlobalSmoothing = 0 GlobalPrediction = 0
from panda3d.core import * from direct.showbase import DConfig import string import types try: language = DConfig.GetString('language', 'english') checkLanguage = DConfig.GetBool('check-language', 0) except: language = simbase.config.GetString('language', 'english') checkLanguage = simbase.config.GetBool('check-language', 0) def getLanguage(): return language print 'OTPLocalizer: Running in language: %s' % language if language == 'english': _languageModule = 'otp.otpbase.OTPLocalizer' + string.capitalize(language) else: checkLanguage = 1 _languageModule = 'otp.otpbase.OTPLocalizer_' + language print 'from ' + _languageModule + ' import *' from otp.otpbase.OTPLocalizerEnglish import * if checkLanguage: l = {} g = {} englishModule = __import__('otp.otpbase.OTPLocalizerEnglish', g, l) foreignModule = __import__(_languageModule, g, l) for key, val in englishModule.__dict__.items(): if not foreignModule.__dict__.has_key(key):
def run(self): try: self._leakDetector._index2containerId2len[self._index] = {} ids = self._leakDetector.getContainerIds() # record the current len of each container for objId in ids: yield None try: for result in self._leakDetector.getContainerByIdGen(objId): yield None container = result except Exception as e: # this container no longer exists if self.notify.getDebug(): for contName in self._leakDetector.getContainerNameByIdGen(objId): yield None self.notify.debug( '%s no longer exists; caught exception in getContainerById (%s)' % ( contName, e)) self._leakDetector.removeContainerById(objId) continue if container is None: # this container no longer exists if self.notify.getDebug(): for contName in self._leakDetector.getContainerNameByIdGen(objId): yield None self.notify.debug('%s no longer exists; getContainerById returned None' % contName) self._leakDetector.removeContainerById(objId) continue try: cLen = len(container) except Exception as e: # this container no longer exists if self.notify.getDebug(): for contName in self._leakDetector.getContainerNameByIdGen(objId): yield None self.notify.debug( '%s is no longer a container, it is now %s (%s)' % (contName, safeRepr(container), e)) self._leakDetector.removeContainerById(objId) continue self._leakDetector._index2containerId2len[self._index][objId] = cLen # compare the current len of each container to past lens if self._index > 0: idx2id2len = self._leakDetector._index2containerId2len for objId in idx2id2len[self._index]: yield None if objId in idx2id2len[self._index-1]: diff = idx2id2len[self._index][objId] - idx2id2len[self._index-1][objId] """ # this check is too spammy if diff > 20: if diff > idx2id2len[self._index-1][objId]: minutes = (self._leakDetector._index2delay[self._index] - self._leakDetector._index2delay[self._index-1]) / 60. name = self._leakDetector.getContainerNameById(objId) if idx2id2len[self._index-1][objId] != 0: percent = 100. * (float(diff) / float(idx2id2len[self._index-1][objId])) try: for container in self._leakDetector.getContainerByIdGen(objId): yield None except: # TODO self.notify.debug('caught exception in getContainerByIdGen (1)') else: self.notify.warning( '%s (%s) grew %.2f%% in %.2f minutes (%s items at last measurement, current contents: %s)' % ( name, itype(container), percent, minutes, idx2id2len[self._index][objId], fastRepr(container, maxLen=CheckContainers.ReprItems))) yield None """ if (self._index > 2 and objId in idx2id2len[self._index-2] and objId in idx2id2len[self._index-3]): diff2 = idx2id2len[self._index-1][objId] - idx2id2len[self._index-2][objId] diff3 = idx2id2len[self._index-2][objId] - idx2id2len[self._index-3][objId] if self._index <= 4: if diff > 0 and diff2 > 0 and diff3 > 0: name = self._leakDetector.getContainerNameById(objId) try: for container in self._leakDetector.getContainerByIdGen(objId): yield None except: # TODO self.notify.debug('caught exception in getContainerByIdGen (2)') else: msg = ('%s (%s) consistently increased in size over the last ' '3 periods (%s items at last measurement, current contents: %s)' % (name, itype(container), idx2id2len[self._index][objId], fastRepr(container, maxLen=CheckContainers.ReprItems))) self.notify.warning(msg) yield None elif (objId in idx2id2len[self._index-4] and objId in idx2id2len[self._index-5]): # if size has consistently increased over the last 5 checks, # send out a warning diff4 = idx2id2len[self._index-3][objId] - idx2id2len[self._index-4][objId] diff5 = idx2id2len[self._index-4][objId] - idx2id2len[self._index-5][objId] if diff > 0 and diff2 > 0 and diff3 > 0 and diff4 > 0 and diff5 > 0: name = self._leakDetector.getContainerNameById(objId) try: for container in self._leakDetector.getContainerByIdGen(objId): yield None except: # TODO self.notify.debug('caught exception in getContainerByIdGen (3)') else: msg = ('leak detected: %s (%s) consistently increased in size over the last ' '5 periods (%s items at last measurement, current contents: %s)' % (name, itype(container), idx2id2len[self._index][objId], fastRepr(container, maxLen=CheckContainers.ReprItems))) self.notify.warning(msg) yield None messenger.send(self._leakDetector.getLeakEvent(), [container, name]) if config.GetBool('pdb-on-leak-detect', 0): import pdb;pdb.set_trace() pass except Exception as e: print('CheckContainers job caught exception: %s' % e) if __dev__: raise yield Job.Done