summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--module/Scheduler.py21
-rw-r--r--module/plugins/Container.py2
2 files changed, 19 insertions, 4 deletions
diff --git a/module/Scheduler.py b/module/Scheduler.py
index f3dfa379e..1b700fc78 100644
--- a/module/Scheduler.py
+++ b/module/Scheduler.py
@@ -17,8 +17,8 @@
@author: mkaay
"""
-from time import sleep, time
-from Queue import PriorityQueue, Empty
+from time import time
+from heapq import heappop, heappush
from threading import Thread
class AlreadyCalled(Exception):
@@ -69,8 +69,8 @@ class Scheduler():
def work(self):
while True:
try:
- t, j = self.queue.get(False)
- except Empty:
+ t, j = self.queue.get()
+ except IndexError:
break
else:
if t <= time():
@@ -96,3 +96,16 @@ class Job(Thread):
self.deferred.callback()
else:
self.deferred.callback(ret)
+
+
+class PriorityQueue():
+ """ a non blocking priority queue """
+ def __init__(self):
+ self.queue = []
+
+ def put(self, element):
+ heappush(self.queue, element)
+
+ def get(self):
+ """ raises IndexError when empty """
+ return heappop(self.queue) \ No newline at end of file
diff --git a/module/plugins/Container.py b/module/plugins/Container.py
index e7b7cc7d6..8d195b4a3 100644
--- a/module/plugins/Container.py
+++ b/module/plugins/Container.py
@@ -37,6 +37,8 @@ class Container(Crypter):
#----------------------------------------------------------------------
def preprocessing(self, thread):
"""prepare"""
+
+ self.setup()
self.thread = thread
self.loadToDisk()