

P = Popen(, stdout=PIPE, bufsize=1) # Note the "-u" flag. My demo below works with the "-u" and it does nothing at all without the flag.Ĭode: Select all Aaron% cat runner.pyĬode: Select all Aaron% cat executor.py It appears that you need to tell the spawned python process to not buffer its output by passing the "-u" flag. Maybe this will point you in the right direction or at least make you aware of the subprocess module if you haven't heard of it. Here is a snippet taken from one of the examples where you can write to the stdin of the spawned process (you can do something similar for reading from stdout as well):Ĭode: Select all proc = subprocess.Popen(, stdin=subprocess.PIPE) It covers writing to and reading from stdin and stdout of a subprocess: This is the Python 2.7 documentation for the subprocess module: Īnd I think this site has a great writeup with some examples on using the module. You can spawn a new process from Python 2.7 code (to run your Python 3 script) and set it up such that the stdin and stdout can be read and written to. I don't have any of my own examples I can provide, but are you familiar with the subprocess module in Python? It sounds like that may be what you want.
