diff options
author | Kartik Patel <kartikpatel1995@gmail.com> | 2017-07-21 01:45:23 +0530 |
---|---|---|
committer | Kartik Patel <kartikpatel1995@gmail.com> | 2017-07-31 17:19:02 +0530 |
commit | 5999bce89cdad39a6eb678b7e4b4063aef211c1d (patch) | |
tree | f4e86d8949c59c4122cc43d92f07f56b0a215cd1 /grc | |
parent | 37d373acee2112b0bb350e5abe09aca0115e5cc6 (diff) |
grc: Terminate instead of kill with Terminate button
Diffstat (limited to 'grc')
-rw-r--r-- | grc/gui/ActionHandler.py | 4 | ||||
-rw-r--r-- | grc/gui/NotebookPage.py | 25 |
2 files changed, 27 insertions, 2 deletions
diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py index 5d48485238..017dab3346 100644 --- a/grc/gui/ActionHandler.py +++ b/grc/gui/ActionHandler.py @@ -626,9 +626,9 @@ class ActionHandler: elif action == Actions.FLOW_GRAPH_KILL: if page.get_proc(): try: - page.get_proc().kill() + page.term_proc() except: - print "could not kill process: %d" % page.get_proc().pid + print "could not terminate process: %d" % page.get_proc().pid elif action == Actions.PAGE_CHANGE: # pass and run the global actions pass elif action == Actions.RELOAD_BLOCKS: diff --git a/grc/gui/NotebookPage.py b/grc/gui/NotebookPage.py index c9e8d0f186..79ad8bf207 100644 --- a/grc/gui/NotebookPage.py +++ b/grc/gui/NotebookPage.py @@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA import pygtk pygtk.require('2.0') import gtk +import gobject import Actions from StateCache import StateCache from Constants import MIN_WINDOW_WIDTH, MIN_WINDOW_HEIGHT @@ -152,6 +153,30 @@ class NotebookPage(gtk.HBox): """ self.process = process + def term_proc(self): + """ + Terminate the subprocess object + + Add a callback to kill the process + after 2 seconds if not already terminated + """ + def kill(process): + """ + Kill process if not already terminated + + Called by gobject.timeout_add + + Returns: + False to stop timeout_add periodic calls + """ + is_terminated = process.poll() + if is_terminated is None: + process.kill() + return False + + self.get_proc().terminate() + gobject.timeout_add(2000, kill, self.get_proc()) + def get_flow_graph(self): """ Get the flow graph. |