Created
July 4, 2019 23:14
-
-
Save dasl-/ebcfb15529eff5d4a7880183b16c30a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import os | |
r,w = os.pipe() | |
proc = subprocess.Popen( | |
"echo 123456123123123123123123123123 >&" + str(w) + " && (sleep 2 && echo bar >&" + str(w) + ") && sleep 4 && exec " + str(w) +"<&- && sleep 6 && echo foo >&" + str(w), | |
shell = True, | |
executable = '/bin/bash', # use bash so we can make use of process subsitution | |
pass_fds = (w,) | |
) | |
os.close(w) | |
has_whole_video_been_processed = False | |
while True: | |
if not has_whole_video_been_processed: | |
in_bytes = os.read(r, 1) | |
if not in_bytes: | |
print("done processing") | |
has_whole_video_been_processed = True | |
break; | |
else: | |
print('read: ' + in_bytes.decode("utf-8")) | |
print("done") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment