mmstats
mmstats copied to clipboard
mmstats files created by new threads can't be cleaned up
The normal pattern to remove mmstats files on exit is:
import mmstats
from mmstats import MmStats
class SomeStats(MmStats):
pass
s = SomeStats()
atexit.register(s.remove)
However if "s" is used from more than 1 thread, a new file is created but not registered for cleanup with atexit.
The fix is to handle cleanup registration within the MmStats.__init__ method with a kwarg like: cleanup=True
Just discovered subclassing threading.local incurs lock acquisition on every attribute access, so I think it's time to drop it altogether.