diff options
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 |