From 5854540acb9478014f3d970ce99bf7223f689e2a Mon Sep 17 00:00:00 2001 From: RaNaN Date: Fri, 5 Nov 2010 23:12:15 +0100 Subject: lock fix --- module/Scheduler.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'module/Scheduler.py') diff --git a/module/Scheduler.py b/module/Scheduler.py index 0032882fc..c145b1582 100644 --- a/module/Scheduler.py +++ b/module/Scheduler.py @@ -68,9 +68,8 @@ class Scheduler(): def work(self): while True: - try: - t, j = self.queue.get() - except IndexError: + t, j = self.queue.get() + if not j: break else: if t <= time(): @@ -110,8 +109,12 @@ class PriorityQueue(): self.lock.release() def get(self): - """ raises IndexError when empty """ + """ return element or None """ self.lock.acquire() - el = heappop(self.queue) - self.lock.release() - return el \ No newline at end of file + try: + el = heappop(self.queue) + return el + except IndexError: + return None,None + finally: + self.lock.release() \ No newline at end of file -- cgit v1.2.3