title: Limiting execution time of embedded Python
body: <p>If I embed the Python interpreter in a C or C++ program, as in <a href="https://docs.python.org/2.7/extending/embedding.html#pure-embedding" rel="noreferrer">this example</a>, 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 <code>PyObject_CallObject</code> (or equivalent) from ever returning?</p>
  
  <p>Similarly, if the Python code creates a new thread, is there anything to stop this thread from entering an infinite loop and running forever?</p>