[gedit] tools: shutdown channels if stop is requested
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] tools: shutdown channels if stop is requested
- Date: Wed, 3 Apr 2013 09:18:56 +0000 (UTC)
commit c159807e4ddb1e85e118cecbe202d4ddf703284b
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Wed Apr 3 11:18:37 2013 +0200
tools: shutdown channels if stop is requested
plugins/externaltools/tools/capture.py | 32 ++++++++++++++++++++++++--------
1 files changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/plugins/externaltools/tools/capture.py b/plugins/externaltools/tools/capture.py
index 58b5787..aeb58f9 100644
--- a/plugins/externaltools/tools/capture.py
+++ b/plugins/externaltools/tools/capture.py
@@ -83,6 +83,10 @@ class Capture(GObject.Object):
self.tried_killing = False
self.idle_write_id = 0
+ self.out_channel = None
+ self.err_channel = None
+ self.out_channel_id = 0
+ self.err_channel_id = 0
try:
self.pipe = subprocess.Popen(self.command, **popen_args)
@@ -100,10 +104,10 @@ class Capture(GObject.Object):
fcntl.fcntl(self.pipe.stdout.fileno(), fcntl.F_SETFL, flags)
self.out_channel = GLib.IOChannel.unix_new(self.pipe.stdout.fileno())
- GLib.io_add_watch(self.out_channel,
- GLib.PRIORITY_DEFAULT,
- GLib.IOCondition.IN | GLib.IOCondition.HUP | GLib.IOCondition.ERR,
- self.on_output)
+ self.out_channel_id = GLib.io_add_watch(self.out_channel,
+ GLib.PRIORITY_DEFAULT,
+ GLib.IOCondition.IN | GLib.IOCondition.HUP |
GLib.IOCondition.ERR,
+ self.on_output)
if self.flags & self.CAPTURE_STDERR:
# Set non blocking
@@ -111,10 +115,10 @@ class Capture(GObject.Object):
fcntl.fcntl(self.pipe.stderr.fileno(), fcntl.F_SETFL, flags)
self.err_channel = GLib.IOChannel.unix_new(self.pipe.stderr.fileno())
- GLib.io_add_watch(self.err_channel,
- GLib.PRIORITY_DEFAULT,
- GLib.IOCondition.IN | GLib.IOCondition.HUP | GLib.IOCondition.ERR,
- self.on_err_output)
+ self.err_channel_id = GLib.io_add_watch(self.err_channel,
+ GLib.PRIORITY_DEFAULT,
+ GLib.IOCondition.IN | GLib.IOCondition.HUP |
GLib.IOCondition.ERR,
+ self.on_err_output)
# IO
if self.input_text is not None:
@@ -179,6 +183,7 @@ class Capture(GObject.Object):
if ret is False and self.out_channel:
self.out_channel.shutdown(True)
self.out_channel = None
+ self.out_channel_id = 0
return ret
@@ -187,6 +192,7 @@ class Capture(GObject.Object):
if ret is False and self.err_channel:
self.err_channel.shutdown(True)
self.err_channel = None
+ self.err_channel = 0
return ret
@@ -196,6 +202,16 @@ class Capture(GObject.Object):
GLib.source_remove(self.idle_write_id)
self.idle_write_id = 0
+ if self.out_channel_id:
+ self.out_channel.shutdown(True)
+ self.out_channel = None
+ self.out_channel_id = 0
+
+ if self.err_channel_id:
+ self.err_channel.shutdown(True)
+ self.err_channel = None
+ self.err_channel = 0
+
if not self.tried_killing:
os.kill(self.pipe.pid, signal.SIGTERM)
self.tried_killing = True
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]