I'm trying to write a game manager/controller for games like Tic-Tac-Toe or checkers/chess that works like this:

Game Arbiter: Controls the gameplay of a game and relays opponent moves to each player. Also determines if a move is a legal one

GamePlayer.py

* Will play a move when asked by the Arbiter

GameArbiter.py

* Will decide which player goes first
* Will decide if move is legal
* Will keep a reference to the two players
* Will ask the correct player for a move and provide current gamestate

The problem I have is how will the Arbiter communicate with the Players? I wanted to use PIPE.communicate() but it seems that only works if the Player terminates after every .communicate() request. My code is as such:

GameArbiter.py:

```
import subprocess
import sys

player1 = subprocess.Popen([sys.executable, "GamePlayer.py"], stdin=subprocess.PIPE, stdout=subprocess.PIPE)

instruction = "GetMove"
out, _ = player1.communicate(instruction.encode())
print(out.decode())     # process input from player

# do some stuff

instruction = "GetMove"
out, _ = player1.communicate(instruction.encode())
print(out.decode())     # process input from player

```

GamePlayer.py:

```
instruction = input()
if(instruction == "GetMove"):
    print("Bc4xc5")
else:
    print("InvalidInstruction")

```

Of course after the second .communicate() python crashes since player1 is no longer an open file

My question is how would I write (in python) a delegate who could actively talk back and forth with multiple children asynchronously?