Bou Baris wrote: >> Instead of using select() use gobject.io_add_watch() on proc.stdout to >> register a callback function that is used to read the % and set the progress >> bar. >> > > I've modified my code to test gobject.io_add_watch() > I expect that test_io_watch() print in console line readed from proc.stdout > But i see nothing: look like a blocking behaviour (as when use Popen > without use select) > If I stop program with CTRL-C, now I see the output to console/terminal > > > def test_io_watch(self, file, condition): > print str(file.readline()) > return True > > def mkv_dts_extraction(self,dtstrack,pgbar=None): > > command=['mkvextract', \ > 'tracks', \ > self.INPUTFILE, \ > dtstrack + ':' + self.TEMP_DTSFILENAME] > > proc=subprocess.Popen(command,stdout=subprocess.PIPE) > > outfile=proc.stdout > outfd=outfile.fileno() > file_flags = fcntl.fcntl(outfd, fcntl.F_GETFL) > fcntl.fcntl(outfd, fcntl.F_SETFL, file_flags | os.O_NDELAY) > > gobject.io_add_watch(proc.stdout,gobject.IO_IN | > gobject.IO_HUP,self.test_io_watch) > > err = proc.wait() > > return True > I think this is due to mkvextract not flushing its output because it's not connected to a tty. Try using a pty in between to fool mkvextract. Something like:
from_mkve, to me = pty.openpty() to_me = os.fdopen(to_me, 'r') file_flags = fcntl.fcntl(to_me, fcntl.F_GETFL) fcntl.fcntl(to_me, fcntl.F_SETFL, file_flags|os.O_NDELAY) proc = subprocess.Popen(command, stdout=from_mkve) gobject.io_add_watch(to_me, gobject.IO_IN|gobject.IO_HUP, self.test_io_watch) John _______________________________________________ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/