Limiting execution time of embedded Python
问题 If I embed the Python interpreter in a C or C++ program, as in this example, is there any way to limit how long the interpreter runs for? Is there anything to stop the Python code from entering an infinite loop and thus preventing PyObject_CallObject (or equivalent) from ever returning? Similarly, if the Python code creates a new thread, is there anything to stop this thread from entering an infinite loop and running forever? 回答1: As you can see in the docs, PyObject_CallObject has no