go - Connecting Golang pipes and Python 2.7 -


i have following task: need connecting go pipe python. understand how run pythonic process under go:

var compiler string = "python" var path string = "...here script path" pyexec := exec.command(compiler, path) pyexecin, _ := pyexec.stdinpipe() pyexecout, _ := pyexec.stdoutpipe() pyexec.start() // acitions pyexec.wait() 

i can write data in stdin read after terminating script. data inside process decide use pipe, can write message pythonic script. when go trying read data python process blocked. answer me please, trouble implementation or goland pipes , pythonic pipes not compatible? exist way connection both process (except socket , on)

go:

var compiler string = "python" var path string = "...here script path" pyexec := exec.command(compiler, path) pyexecin, _ := pyexec.stdinpipe() pyexecout, _ := pyexec.stdoutpipe() pipereader, pipewriter := io.pipe() pyexec.stdin = pipereader pyexec.stdout = pipewriter pyexec.start() pipewriter.write(message) var received_data = make([]byte, 1024) data, _ := pipereader.read(received_data) pyexecin.close() pyexecout.close() pyexec.wait() 

python:

r, w = os.pipe() r = os.fdopen(r, 'r') raw_responce = r.read(1024) # actions w = os.fdopen(w, 'w') w.write(data) 

thanks


Comments