Skip to content

Instantly share code, notes, and snippets.

@june9713
Created July 23, 2017 16:37
Show Gist options
  • Save june9713/e9e19a0993cc4006ac17d834dc7dc2a5 to your computer and use it in GitHub Desktop.
Save june9713/e9e19a0993cc4006ac17d834dc7dc2a5 to your computer and use it in GitHub Desktop.
import sys
import subprocess
import threading
import os
#### test.py ########
#import sys
#print("path is " , sys.argv[1])
#print("This is test")
#####################
process = ''
def checkPout():
global process
while True:
out = process.stdout.read(1)
if out == b'' and process.poll() != None:
break
if out != b'':
sys.stdout.write(out.decode())
sys.stdout.flush()
yourpath = os.getcwd()
cmd ="python test1.py --path=%s"%(yourpath)
process = subprocess.Popen(cmd,stdout = subprocess.PIPE,stderr = subprocess.PIPE,shell=True)
th = threading.Thread(target= checkPout )
th.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment