def _clean_tmp(self): removed = [] for path in self._alive: try: os.unlnk(path) except: pass else: removed.append(path) self._alive.difference_update(removed)