[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r8928 - gnuradio/branches/features/mp-sched/gnuradio-c
From: |
eb |
Subject: |
[Commit-gnuradio] r8928 - gnuradio/branches/features/mp-sched/gnuradio-core/src/python/gnuradio/gr |
Date: |
Thu, 17 Jul 2008 15:11:41 -0600 (MDT) |
Author: eb
Date: 2008-07-17 15:11:38 -0600 (Thu, 17 Jul 2008)
New Revision: 8928
Modified:
gnuradio/branches/features/mp-sched/gnuradio-core/src/python/gnuradio/gr/top_block.py
Log:
^C now interrupts top_block.run() and top_block.wait(), even in python's main
thread.
Modified:
gnuradio/branches/features/mp-sched/gnuradio-core/src/python/gnuradio/gr/top_block.py
===================================================================
---
gnuradio/branches/features/mp-sched/gnuradio-core/src/python/gnuradio/gr/top_block.py
2008-07-17 21:07:52 UTC (rev 8927)
+++
gnuradio/branches/features/mp-sched/gnuradio-core/src/python/gnuradio/gr/top_block.py
2008-07-17 21:11:38 UTC (rev 8928)
@@ -22,7 +22,34 @@
from gnuradio_swig_python import top_block_swig, \
top_block_wait_unlocked, top_block_run_unlocked
+#import gnuradio.gr.gr_threading as _threading
+import gr_threading as _threading
+
+
#
+# There is no problem that can't be solved with an additional
+# level of indirection...
+#
+# This kludge allows ^C to interrupt top_block.run and top_block.wait
+#
+class _top_block_waiter(_threading.Thread):
+ def __init__(self, tb):
+ _threading.Thread.__init__(self)
+ self.setDaemon(1)
+ self.tb = tb
+ self.event = _threading.Event()
+ self.start()
+
+ def run(self):
+ top_block_wait_unlocked(self.tb)
+ self.event.set()
+
+ def wait(self):
+ while True:
+ self.event.wait(0.100)
+
+
+#
# This hack forces a 'has-a' relationship to look like an 'is-a' one.
#
# It allows Python classes to subclass this one, while passing through
@@ -48,11 +75,13 @@
self._tb.stop()
def run(self):
- top_block_run_unlocked(self._tb)
+ self.start()
+ self.wait()
def wait(self):
- top_block_wait_unlocked(self._tb)
+ _top_block_waiter(self._tb).wait()
+
# FIXME: these are duplicated from hier_block2.py; they should really be
implemented
# in the original C++ class (gr_hier_block2), then they would all be
inherited here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r8928 - gnuradio/branches/features/mp-sched/gnuradio-core/src/python/gnuradio/gr,
eb <=