Perhaps I asked the question a little incorrectly, here's how I do it:
type
TPyThread = class(TPythonThread)
protected
procedure ExecuteWithPython; override;
public
constructor Сreate(createsuspended: boolean);
end;
procedure ExecPythonFile(const FFile, Params:string);
const
Arg: string =
'import sys' + #10 +
'def run_python_script(args_str):'+#10+
' args_list = args_str.split()'+#10+
' sys.argv = [sys.argv[0]] + args_list';
var
Py: IPyEngineAndGIL;
begin
try
PythonEngine.ExecString(Arg+#10+'run_python_script("'+Params+'")');
PythonEngine.ExecFile(FFile);
finally
end;
end;
constructor TPyThread.Сreate(createsuspended: boolean);
begin
inherited Create(CreateSuspended);
ThreadExecMode:=emNewInterpreterOwnGIL; // I USE Python12.dll
FreeOnTerminate:=True;
end;
procedure TPyThread.ExecuteWithPython;
while true do
ExecPythonFile(myfilename,'-i 2000 --r');
end;
My software just crashes after a while, please help
In one thread it works fine, but at 10 the software crashes