summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-11-05 23:12:15 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-11-05 23:12:15 +0100
commit5854540acb9478014f3d970ce99bf7223f689e2a (patch)
tree3d6d5421f458fe5c1206456fb6be93b0b259b3f7
parentfixes (diff)
downloadpyload-5854540acb9478014f3d970ce99bf7223f689e2a.tar.xz
lock fix
-rw-r--r--module/Scheduler.py17
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