From novermore at gmail.com Thu Jun 9 13:53:00 2011 From: novermore at gmail.com (Alex) Date: Thu, 9 Jun 2011 14:53:00 +0300 Subject: [capi-sig] embedded. how to force stop sub-interpreter from c Message-ID: 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? From novermore at gmail.com Thu Jun 9 18:32:43 2011 From: novermore at gmail.com (Alex) Date: Thu, 9 Jun 2011 19:32:43 +0300 Subject: [capi-sig] embedded. how to force stop sub-interpreter from c In-Reply-To: References: Message-ID: 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? ---------- Forwarded message ---------- From: Alex Date: 2011/6/9 Subject: embedded. how to force stop sub-interpreter from c To: capi-sig at python.org 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?