aboutsummaryrefslogtreecommitdiff
path: root/drivers.py
diff options
context:
space:
mode:
Diffstat (limited to 'drivers.py')
-rw-r--r--drivers.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers.py b/drivers.py
new file mode 100644
index 0000000..0c14018
--- /dev/null
+++ b/drivers.py
@@ -0,0 +1,27 @@
+import Queue
+from threading import Timer
+
+class Processor(object):
+ def __init__(self, input_queue):
+ self.input_queue = input_queue
+ self.listeners = []
+ def again(self, t):
+ next_run = Timer(t, self.do)
+ next_run.start()
+ def do(self):
+ """
+ The do method should:
+ Consider input in the input queue
+ call self.again(timeDelay)
+ call self.done(data)
+ In that order
+ """
+ raise NotImplementedError("proc must be defined")
+ def done(self, data):
+ [l.handle(data) for l in self.listeners]
+ #todo [rcoh] - there should be a better way to do this.
+
+
+class Listener(object):
+ def handle(self, data):
+ raise NotImplementedError("handle must be defined")