
i am using PyThreadState* Py_NewInterpreter() to create few sub-interpreters in own c threads
there is only pure python in a scrips running in sub-interpreters
here is how sub-interpreter started (delphi..no differences with c)
gilstate := PyGILState_Ensure(); global_state := PyThreadState_Get; PyThreadState_Swap(nil); fThreadState := Py_NewInterpreter;
if Assigned(fThreadState) then begin PyThreadState_Swap(fThreadState); PyRun_String('some python code'); Py_EndInterpreter(fThreadState); PyThreadState_Swap(global_state); PyGILState_Release(gilstate); end else raise EPythonError.Create( 'Could not create a new thread state'); all works fine, they run, they die when script ends
but i cant figure out how to force stop sub-interpreter from c
for example there is a python script
while True: time.sleep(3)
i need to stop this script and sub-interpreter from main program, how can i do that?