File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -9651,7 +9651,8 @@ procedure TPythonThread.Execute;
96519651 finally
96529652 PyGILState_Release(gilstate);
96539653 end ;
9654- end else
9654+ end
9655+ else
96559656 begin
96569657 gilstate := PyGILState_Ensure();
96579658 global_state := PyThreadState_Get;
@@ -9665,22 +9666,26 @@ procedure TPythonThread.Execute;
96659666 PyStatus_Exception(Py_NewInterpreterFromConfig(@fThreadState, @Config))
96669667 then
96679668 fThreadState := Py_NewInterpreter
9668- else
9669+ else if Assigned(IOPythonModule) then
96699670 // flag IOPythonModule as per interpreter GIL compatible
96709671 TPythonModule(IOPythonModule).MultInterpretersSupport := mmiPerInterpreterGIL;
96719672
96729673 if Assigned(fThreadState) then
96739674 begin
96749675 PyThreadState_Swap(fThreadState);
96759676 // Redirect IO
9676- TPythonModule(IOPythonModule).InitializeForNewInterpreter;
9677- DoRedirectIO;
9677+ if RedirectIO and Assigned(IOPythonModule) then
9678+ begin
9679+ TPythonModule(IOPythonModule).InitializeForNewInterpreter;
9680+ DoRedirectIO;
9681+ end ;
96789682 // Execute the python code
96799683 ExecuteWithPython;
96809684 Py_EndInterpreter( fThreadState);
96819685 PyThreadState_Swap(global_state);
96829686 PyGILState_Release(gilstate);
9683- end else
9687+ end
9688+ else
96849689 raise EPythonError.Create(SCannotCreateThreadState);
96859690 end ;
96869691 end ;
You can’t perform that action at this time.
0 commit comments