[pygtk] Non-blocking subprocess.Popen stop GUI
Bou Baris
boubaris at gmail.com
Mon Aug 31 14:14:17 WST 2009
> 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)
>
Thanks for your suggestion. This evening when I come back @home I'll try it.
BTW if 'mkvextract' doesn't flush its output, I should have the same
problem running my original code that use 'select'.
Using 'select' is fine, there is no block to the flow due to lack of
stdout flush, BUT the problem is GUI that is stopped.
One hour ago I've also tried with thread (using module thread and
thread.start_new_thread() function).
The same behaviour...... GUI is stopped until subprocess.Popen() end.
I'm a bit confused ....
More information about the pygtk
mailing list