Skip to content

Commit

Permalink
Perform thread locking in remove()
Browse files Browse the repository at this point in the history
  • Loading branch information
bitprophet committed Apr 25, 2013
1 parent 68c0b50 commit 632e6c3
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions mmstats/models.py
Expand Up @@ -125,13 +125,14 @@ def flush(self, async=False):
_mmap.msync(self._mm_ptr, self._size, async)

def remove(self):
# Perform regular removal of this process/thread's own file.
self._remove()
# Then ensure we clean up any forgotten thread-related files, if
# applicable. Ensure {PID} exists, for safety's sake - better to not
# cleanup than to cleanup multiple PIDs' files.
if '{PID}' in self._filename and '{TID}' in self._filename:
self._remove_stale_thread_files()
with threading.Lock():
# Perform regular removal of this process/thread's own file.
self._remove()
# Then ensure we clean up any forgotten thread-related files, if
# applicable. Ensure {PID} exists, for safety's sake - better to not
# cleanup than to cleanup multiple PIDs' files.
if '{PID}' in self._filename and '{TID}' in self._filename:
self._remove_stale_thread_files()

def _remove_stale_thread_files(self):
# The originally given (to __init__) filename string, containing
Expand Down

0 comments on commit 632e6c3

Please sign in to comment.