Thanks for the input.
The thing is I want to communicate with python both ways. Like.
Sending commands to python.
And then.
Receiving back the results.
Without restarting the python engine all the time.
I found a way to get the output but its pretty slow (around 200ms per command) when I use "TProcess.CloseInput;" I can read the output, but the problem is that it also exits python and I have to restart it with "TProcess.execute" then. Which is all rather slow.
This works but exits the python engine.
var
AProcess : Tprocess
buf ..
...
Begin
AProcess.SetCommandline('C:\...\python.exe');
AProcess.setOptions([poUsePipes]);
AProcess.execute;
//We get output using this, but it closes python and It has to be restarted for more commands.
cmd:= 'print("testabc")'+#10;
Aprocess.getInput().Write(cmd[1],length(cmd));
AProcess.CloseInput;
repeat
count := AProcess.Output.Read(buf, AProcess.Output.getNumBytesAvailable);
until AProcess.getOutput().getNumBytesAvailable = 0;
Edit:
This line takes like 200ms to process. Everything else is actually fast. Gotta test more later.
If anyone has an idea how to get it faster please share
Would be much appreciated.
//very slow execution around 200ms
AProcess.Output.Read(buf, AProcess.Output.getNumBytesAvailable);