diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-11-05 22:54:05 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-11-05 22:54:05 +0100 |
commit | 6820ab66f95371336dbe72df2efa679b609fed6d (patch) | |
tree | 19a8d9151f5dd1a2cf731cb28ee374a1d39f5ad3 /module/Scheduler.py | |
parent | new priority queue (diff) | |
download | pyload-6820ab66f95371336dbe72df2efa679b609fed6d.tar.xz |
fixes
Diffstat (limited to 'module/Scheduler.py')
-rw-r--r-- | module/Scheduler.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/module/Scheduler.py b/module/Scheduler.py index 1b700fc78..0032882fc 100644 --- a/module/Scheduler.py +++ b/module/Scheduler.py @@ -19,7 +19,7 @@ from time import time from heapq import heappop, heappush -from threading import Thread +from threading import Thread, Lock class AlreadyCalled(Exception): pass @@ -49,7 +49,7 @@ class Deferred(): raise AlreadyCalled self.result = (args, kwargs) for f, cargs, ckwargs in self.call: - args.extend(cargs) + args+=tuple(cargs) kwargs.update(ckwargs) callInThread(f, *args, **kwargs) @@ -102,10 +102,16 @@ class PriorityQueue(): """ a non blocking priority queue """ def __init__(self): self.queue = [] + self.lock = Lock() def put(self, element): + self.lock.acquire() heappush(self.queue, element) + self.lock.release() def get(self): """ raises IndexError when empty """ - return heappop(self.queue)
\ No newline at end of file + self.lock.acquire() + el = heappop(self.queue) + self.lock.release() + return el
\ No newline at end of file |