From 6820ab66f95371336dbe72df2efa679b609fed6d Mon Sep 17 00:00:00 2001 From: RaNaN Date: Fri, 5 Nov 2010 22:54:05 +0100 Subject: fixes --- module/Scheduler.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'module/Scheduler.py') 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 -- cgit v1.2.3