I would also recommend using ExternalEvaluate for this kind of interaction with python. But you can keep everything the way you have it with just a small change.
First I add a print statement at the end of the python script to signal when it has finished writing the file, just something like print("finished")
Then call ReadLine[process] after the ...
Look at ExternalEvaluate if you have v12.0? The python computations will by design be 'blocking' using this approach, i.e. the Wolfram Kernel will wait on the ExternalEvaluate to finish.
Here's your simple example using TemplateExpression:
session = StartExternalSession["Python"];
x = <* x *>
y = <* y *>