> And if you change the deque for a Queue.Queue, you don't even need a > Lock... > > Cheers, > > Maxime
Maxime, thanks, sched module could be a nice solution. I've never used it before but it seems to be the right way. You guessed right. I want to used it in Queue. But this implementation does not guarantee that __cleanup__ won't be invoked while __contains__ processing. > def _remove(self, rec): #try not to use __form, almost always an error > self.records.remove(rec) > > the Timer would become > Timer(ttl, self._remove, [(t, item)]) # t is the time that you got > before This solution has one shortcoming. When record() called many times during short period (almost simultaneously) the _remove(item) calls do not manage to remove records on time. So I choosed batch cleanup. But thanks for suggestion! I'll try sched. -- http://mail.python.org/mailman/listinfo/python-list