mmstats icon indicating copy to clipboard operation
mmstats copied to clipboard

mmstats files created by new threads can't be cleaned up

Open schmichael opened this issue 12 years ago • 1 comments

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

schmichael avatar Apr 23 '13 23:04 schmichael

Just discovered subclassing threading.local incurs lock acquisition on every attribute access, so I think it's time to drop it altogether.

schmichael avatar Apr 24 '13 17:04 schmichael