don't re-print garbage info if no new garbage

This commit is contained in:
Darren Ranalli 2009-01-26 22:54:50 +00:00
parent df3fe996b9
commit 90eb2bf52e

View File

@ -509,6 +509,8 @@ class GarbageReport(Job):
class GarbageLogger(GarbageReport):
"""If you just want to log the current garbage to the log file, make
one of these. It automatically destroys itself after logging"""
# variable for checkForGarbageLeaks
LastNumGarbage = 0
def __init__(self, name, *args, **kArgs):
kArgs['log'] = True
kArgs['autoDestroy'] = True
@ -517,7 +519,9 @@ class GarbageLogger(GarbageReport):
def checkForGarbageLeaks():
gc.collect()
numGarbage = len(gc.garbage)
if numGarbage and not configIsToday('disable-garbage-logging'):
if ((numGarbage != GarbageLogger.LastNumGarbage) and
(not configIsToday('disable-garbage-logging'))):
GarbageLogger.LastNumGarbage = numGarbage
print
gr = GarbageLogger('found garbage', threaded=False)
print