Example #1
0
 def addExclObjs(cls, *objs):
     for obj in makeList(objs):
         if id(obj) not in cls._ExclObjIds:
             cls._ExclObjs.append(obj)
         cls._ExclObjIds.setdefault(id(obj), 0)
         cls._ExclObjIds[id(obj)] += 1
     cls._SyncMaster.change()
Example #2
0
 def addExclObjs(cls, *objs):
     for obj in makeList(objs):
         if id(obj) not in cls._ExclObjIds:
             cls._ExclObjs.append(obj)
         cls._ExclObjIds.setdefault(id(obj), 0)
         cls._ExclObjIds[id(obj)] += 1
     cls._SyncMaster.change()
Example #3
0
 def removeExclObjs(cls, *objs):
     for obj in makeList(objs):
         assert id(obj) in cls._ExclObjIds
         cls._ExclObjIds[id(obj)] -= 1
         if cls._ExclObjIds[id(obj)] == 0:
             del cls._ExclObjIds[id(obj)]
             cls._ExclObjs.remove(obj)
     cls._SyncMaster.change()
Example #4
0
 def removeExclObjs(cls, *objs):
     for obj in makeList(objs):
         assert id(obj) in cls._ExclObjIds
         cls._ExclObjIds[id(obj)] -= 1
         if cls._ExclObjIds[id(obj)] == 0:
             del cls._ExclObjIds[id(obj)]
             cls._ExclObjs.remove(obj)
     cls._SyncMaster.change()
Example #5
0
 def typeFreqStr(self):
     s = 'Object Pool: Type Frequencies'
     s += '\n============================='
     counts = list(set(self._count2types.keys()))
     counts.sort()
     counts.reverse()
     for count in counts:
         types = makeList(self._count2types[count])
         for typ in types:
             s += '\n%s\t%s' % (count, typ)
     return s
Example #6
0
 def __init__(self, name, postNames, callback, removeNames=None):
     self.notify.debug('__init__: %s, %s, %s' % (name, postNames, callback))
     if removeNames is None:
         removeNames = []
     self.name = name
     self.postNames = makeList(postNames)
     self.removeNames = makeList(removeNames)
     self.callback = callback
     self.waitingOn = set()
     for name in self.postNames:
         if not bboard.has(name):
             eventName = bboard.getEvent(name)
             self.waitingOn.add(eventName)
             self.acceptOnce(eventName, Functor(self._handleEvent, eventName))
     for name in self.removeNames:
         if bboard.has(name):
             eventName = bboard.getRemoveEvent(name)
             self.waitingOn.add(eventName)
             self.acceptOnce(eventName, Functor(self._handleEvent, eventName))
     self._checkDone()
Example #7
0
 def typeFreqStr(self):
     s = "Object Pool: Type Frequencies"
     s += "\n============================="
     counts = list(set(self._count2types.keys()))
     counts.sort()
     counts.reverse()
     for count in counts:
         types = makeList(self._count2types[count])
         for typ in types:
             s += "\n%s\t%s" % (count, typ)
     return s
Example #8
0
 def __init__(self, name, postNames, callback, removeNames=None):
     self.notify.debug('__init__: %s, %s, %s' % (name, postNames, callback))
     if removeNames is None:
         removeNames = []
     self.name = name
     self.postNames = makeList(postNames)
     self.removeNames = makeList(removeNames)
     self.callback = callback
     self.waitingOn = set()
     for name in self.postNames:
         if not bboard.has(name):
             eventName = bboard.getEvent(name)
             self.waitingOn.add(eventName)
             self.acceptOnce(eventName, Functor(self._handleEvent,
                                                eventName))
     for name in self.removeNames:
         if bboard.has(name):
             eventName = bboard.getRemoveEvent(name)
             self.waitingOn.add(eventName)
             self.acceptOnce(eventName, Functor(self._handleEvent,
                                                eventName))
     self._checkDone()
Example #9
0
 def printObjsByType(self, printReferrers=False):
     print "Object Pool: Objects By Type"
     print "\n============================"
     counts = list(set(self._count2types.keys()))
     counts.sort()
     # print types with the smallest number of instances first, in case
     # there's a large group that waits a long time before printing
     # counts.reverse()
     for count in counts:
         types = makeList(self._count2types[count])
         for typ in types:
             print "TYPE: %s, %s objects" % (repr(typ), len(self._type2objs[typ]))
             if printReferrers:
                 for line in getNumberedTypedSortedStringWithReferrersGen(self._type2objs[typ]):
                     print line
             else:
                 print getNumberedTypedSortedString(self._type2objs[typ])
Example #10
0
 def printReferrers(self, numEach=3):
     """referrers of the first few of each type of object"""
     counts = list(set(self._count2types.keys()))
     counts.sort()
     counts.reverse()
     for count in counts:
         types = makeList(self._count2types[count])
         for typ in types:
             print "\n\nTYPE: %s" % repr(typ)
             for i in xrange(min(numEach, len(self._type2objs[typ]))):
                 obj = self._type2objs[typ][i]
                 print "\nOBJ: %s\n" % safeRepr(obj)
                 referrers = gc.get_referrers(obj)
                 print "%s REFERRERS:\n" % len(referrers)
                 if len(referrers):
                     print getNumberedTypedString(referrers, maxLen=80, numPrefix="REF")
                 else:
                     print "<No Referrers>"
Example #11
0
 def printObjsByType(self, printReferrers=False):
     print 'Object Pool: Objects By Type'
     print '\n============================'
     counts = list(set(self._count2types.keys()))
     counts.sort()
     # print types with the smallest number of instances first, in case
     # there's a large group that waits a long time before printing
     #counts.reverse()
     for count in counts:
         types = makeList(self._count2types[count])
         for typ in types:
             print 'TYPE: %s, %s objects' % (repr(typ),
                                             len(self._type2objs[typ]))
             if printReferrers:
                 for line in getNumberedTypedSortedStringWithReferrersGen(
                         self._type2objs[typ]):
                     print line
             else:
                 print getNumberedTypedSortedString(self._type2objs[typ])
Example #12
0
 def printReferrers(self, numEach=3):
     """referrers of the first few of each type of object"""
     counts = list(set(self._count2types.keys()))
     counts.sort()
     counts.reverse()
     for count in counts:
         types = makeList(self._count2types[count])
         for typ in types:
             print '\n\nTYPE: %s' % repr(typ)
             for i in xrange(min(numEach, len(self._type2objs[typ]))):
                 obj = self._type2objs[typ][i]
                 print '\nOBJ: %s\n' % safeRepr(obj)
                 referrers = gc.get_referrers(obj)
                 print '%s REFERRERS:\n' % len(referrers)
                 if len(referrers):
                     print getNumberedTypedString(referrers,
                                                  maxLen=80,
                                                  numPrefix='REF')
                 else:
                     print '<No Referrers>'