schedule: Move the whole deletion of an event in the same critical section.

This commit is contained in:
Valentin Lorentz 2014-06-17 21:19:07 +02:00
parent 8ec9f1b496
commit 9e74175566

View File

@ -136,8 +136,7 @@ class Schedule(drivers.IrcDriver):
while self.schedule and self.schedule[0][0] < time.time(): while self.schedule and self.schedule[0][0] < time.time():
with self.lock: with self.lock:
(t, name, args, kwargs) = heapq.heappop(self.schedule) (t, name, args, kwargs) = heapq.heappop(self.schedule)
f = self.events[name] f = self.events.pop(name)
del self.events[name]
try: try:
f(*args, **kwargs) f(*args, **kwargs)
except Exception as e: except Exception as e: