Author: tack
Date: Mon Feb 4 20:13:13 2008
New Revision: 3031
Log:
New close_stdin() method (see docstring)
Modified:
trunk/base/src/notifier/popen.py
Modified: trunk/base/src/notifier/popen.py
==============================================================================
--- trunk/base/src/notifier/popen.py (original)
+++ trunk/base/src/notifier/popen.py Mon Feb 4 20:13:13 2008
@@ -97,6 +97,7 @@
self.in_progress = None
self._write_buffer = []
self._wmon = None
+ self._close_stdin = False
def _normalize_cmd(self, cmd):
@@ -190,12 +191,31 @@
return self.child.pid
+ def close_stdin(self):
+ """
+ Closes stdin either now, or once the write buffer has been flushed.
+ This might be necessary when, for example, we know we have nothing
+ more to send to the child, but the child is waiting for either more
+ data or a closed fd before outputting data we're interested in.
+ """
+ if not self.child:
+ return
+
+ if self._wmon and self._wmon.active():
+ self._close_stdin = True
+ else:
+ self.child.tochild.close()
+
+
def write(self, data):
"""
Queue data for writing when the child is ready to receive it.
"""
+ if self.child.tochild.closed:
+ raise ValueError("Can't write when stdin has been closed")
+
self._write_buffer.append(data)
- if self._wmon and not self._wmon.active():
+ if self.child and self._wmon and not self._wmon.active():
self._wmon.register(self.child.tochild, IO_WRITE)
@@ -219,6 +239,8 @@
return
if not self._write_buffer:
+ if self._close_stdin:
+ self.child.tochild.close()
return False
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog