embedded. how to force stop sub-interpreter from c
![](https://secure.gravatar.com/avatar/01f37af999f8998878d42dcde048459c.jpg?s=120&d=mm&r=g)
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?
![](https://secure.gravatar.com/avatar/01f37af999f8998878d42dcde048459c.jpg?s=120&d=mm&r=g)
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 <novermore@gmail.com> Date: 2011/6/9 Subject: embedded. how to force stop sub-interpreter from c To: capi-sig@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?
participants (1)
-
Alex