I'll try to make it straightforward to reproduce, so that you can see the collision.
python
import os; os.getpid(); # we'll need this, get it to clipboard or something
296236 # for me
import subprocess
subprocess.Popen('python')
<subprocess.Popen object at somewhere_over_the_rainbow> # object is created, python probably waits for a chance to push it to the console as a command "python"
>>>
<import&get pid>
296236 # the command is pushed, the new process spawned
You spawned another Python process into a current open console that already waits for an input. The "child" process now exists but still can't demand to get an input, because the main one is still "on the turn". Imagine it like a queue. The output for import os;os.getpid() now will still be the main process' PID and now the child one gets its turn.
<import&get pid>
296236
>>> Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information. # from second process, it did its stuff in its turn, now main process wants to talk
<import&get pid> # in main process
296236
<import&get pid> # in second process
296800
<import&get pid> # in main process
296236
<import&get pid> #in second process
296800
...and alternating again and again. The fun begins when you want to exit(), because the fight for input is still ongoing:
import os;os.getpid();exit() #in second process
296800
and a clean empty line
import os;os.getpid();exit() #in main process
296236
C:\some folder>
Basically it fights for an IO operation in a queue because you're doing something stupid. If you need to use it, just interpret a file and definitely not in an already opened interpreter, but also in a separate file. For example:
main.py
import subprocess
subprocess.Popen('python other.py')
other.py
print('hello')
exit()
console
python main.py
exitorquit, I'm sure.Popenthe object is created, then<enter>, and then the new interpreter prints to the current one. If you then type right after the interpreter is opened e.g.help(), it'll be interpreted in the first one, while now the second one waits for your input. If now you give it<enter>, the second interpreter just "passes" and thehelp()output continues...python main.py, where in main.py you call that subprocess and the string is also something likepython second_main.py. Maybe it'd be better to explain it with twoinput()functions waiting for each other?