Communication with Stockfish engine via Python I try to access the Stockfish engine via Python, but only get bestmove = a2a3. 
If I enter the same commands into the MAC-terminal, the engine calculates the correct move. 
Can anyone help me, please ? 

My Python code is: 

p = subprocess.Popen('/Applications/TigerJython/LuChess/Stockfish/stockfish-11-mac/Mac/stockfish-11-64', stdin=subprocess.PIPE,
                     stdout=subprocess.PIPE,
                     stderr=subprocess.STDOUT)

p.stdin.write("uci\n")
p.stdin.write("ucinewgame\n")
p.stdin.write("position startpos moves e2e4 e7e5\n")
p.stdin.write("go infinite\n")
p.stdin.flush()
print(p.communicate())


The result is shown below:

('Stockfish 11 64 by T. Romstad, M. Costalba, J. Kiiski, G. Linscott
id name Stockfish 11 64\nid author T. Romstad, M. Costalba, J. Kiiski, G. Linscott

option name Debug Log File type string default
option name Contempt type spin default 24 min -100 max 100
...
uciok
bestmove a2a3
None
The Problem was p.communicate(), which kills the subprocess. The interaction with the engine works well with the following code:

def put(command, inf_list, tmp_time):

    engine.stdin.write(command+'\n')
    engine.stdin.flush()
    time.sleep(tmp_time)

    if command &lt;&gt; "quit":

        engine.stdin.write('isready\n')     
        engine.stdin.flush()

        while True:
            text = engine.stdout.readline().strip()

            if text == 'readyok':
                break

            elif text !='':
                inf_list.append(text)


inf_list = []
put('uci', inf_list, 0)
put('setoption name Hash value 8192', inf_list, 0)
put('ucinewgame', inf_list, 0)
put('position fen rq3r2/2pbppk1/3p1np1/1N5p/1n1PP2P/2N2P2/PP1Q2P1/R3KB1R w KQ - 3 15', inf_list, 0)
put('go movetime=3000', inf_list, 4)
put('stop', inf_list, 0)
put('quit', inf_list, 0)