diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-11-05 23:12:15 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-11-05 23:12:15 +0100 |
commit | 5854540acb9478014f3d970ce99bf7223f689e2a (patch) | |
tree | 3d6d5421f458fe5c1206456fb6be93b0b259b3f7 /module | |
parent | fixes (diff) | |
download | pyload-5854540acb9478014f3d970ce99bf7223f689e2a.tar.xz |
lock fix
Diffstat (limited to 'module')
-rw-r--r-- | module/Scheduler.py | 17 |
1 files changed, 10 insertions, 7 deletions
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 |