diff options
author | rcoh <rcoh@mit.edu> | 2011-08-02 22:02:50 -0700 |
---|---|---|
committer | rcoh <rcoh@mit.edu> | 2011-08-02 22:02:50 -0700 |
commit | 0dcc566d84f109a6026c60aeaebe4187a34f892d (patch) | |
tree | 9b75742349abe421272f730dc62fc17142c9b8a8 /driverdemo.py | |
parent | ea209dc1b261a9e6358204c6d93f71854394e08c (diff) |
adding driver classes and a demo of how to use them.
Diffstat (limited to 'driverdemo.py')
-rw-r--r-- | driverdemo.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/driverdemo.py b/driverdemo.py new file mode 100644 index 0000000..1c359b5 --- /dev/null +++ b/driverdemo.py @@ -0,0 +1,30 @@ +from drivers import * +from threading import * +import Queue +class TestProcessor(Processor): + def do(self): + data = [] + if not self.input_queue.empty(): + data.append(self.input_queue.get(False)) + self.again(.1) + self.done(data) + +class TestListener(Listener): + def handle(self, data): + print data + print active_count() + +def addToQueue(): + queue.put("test") + again = Timer(.5, addToQueue) + again.start() + +queue = Queue.Queue() +t = TestProcessor(queue) +l = TestListener() +t.listeners.append(l) +queue = t.input_queue +t.do() +addToQueue() + + |