[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r10068 - in gnuradio/branches/features/cppdb/gnuradio-
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r10068 - in gnuradio/branches/features/cppdb/gnuradio-core/src: lib/runtime python/gnuradio/gr |
Date: |
Wed, 26 Nov 2008 11:08:55 -0700 (MST) |
Author: jcorgan
Date: 2008-11-26 11:08:54 -0700 (Wed, 26 Nov 2008)
New Revision: 10068
Modified:
gnuradio/branches/features/cppdb/gnuradio-core/src/lib/runtime/gr_top_block.i
gnuradio/branches/features/cppdb/gnuradio-core/src/python/gnuradio/gr/top_block.py
Log:
Fix shutdown failure when some flowgraphs are interrupted with Ctrl-C.
Modified:
gnuradio/branches/features/cppdb/gnuradio-core/src/lib/runtime/gr_top_block.i
===================================================================
---
gnuradio/branches/features/cppdb/gnuradio-core/src/lib/runtime/gr_top_block.i
2008-11-26 03:08:44 UTC (rev 10067)
+++
gnuradio/branches/features/cppdb/gnuradio-core/src/lib/runtime/gr_top_block.i
2008-11-26 18:08:54 UTC (rev 10068)
@@ -63,4 +63,11 @@
r->wait();
Py_END_ALLOW_THREADS; // acquire global interpreter lock
}
+
+// Shortcut to allow Python to directory call low-level stop(),
+// used in gr_top_block.py
+void top_block_stop(gr_top_block_sptr r)
+{
+ r->stop();
+}
%}
Modified:
gnuradio/branches/features/cppdb/gnuradio-core/src/python/gnuradio/gr/top_block.py
===================================================================
---
gnuradio/branches/features/cppdb/gnuradio-core/src/python/gnuradio/gr/top_block.py
2008-11-26 03:08:44 UTC (rev 10067)
+++
gnuradio/branches/features/cppdb/gnuradio-core/src/python/gnuradio/gr/top_block.py
2008-11-26 18:08:54 UTC (rev 10068)
@@ -1,5 +1,5 @@
#
-# Copyright 2007 Free Software Foundation, Inc.
+# Copyright 2007,2008 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -20,12 +20,11 @@
#
from gnuradio_swig_python import top_block_swig, \
- top_block_wait_unlocked, top_block_run_unlocked
+ top_block_wait_unlocked, top_block_run_unlocked, top_block_stop
#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...
@@ -37,18 +36,27 @@
_threading.Thread.__init__(self)
self.setDaemon(1)
self.tb = tb
+ self.interrupted = False
self.event = _threading.Event()
self.start()
def run(self):
top_block_wait_unlocked(self.tb)
- self.event.set()
+ # Don't set event if interrupted as internal Python state is
+ # no longer reliable in this thread context
+ if not self.interrupted:
+ self.event.set()
def wait(self):
- while not self.event.isSet():
- self.event.wait(0.100)
+ try:
+ while not self.event.isSet():
+ self.event.wait(0.100)
+ except KeyboardInterrupt:
+ # top_block_wait_unlocked above is still blocked waiting for
+ # flowgraph threads to finish, so we must force flowgraph to stop
+ self.interrupted = True
+ top_block_stop(self.tb) # gr_top_block.i
-
#
# This hack forces a 'has-a' relationship to look like an 'is-a' one.
#
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r10068 - in gnuradio/branches/features/cppdb/gnuradio-core/src: lib/runtime python/gnuradio/gr,
jcorgan <=