title: Kill a python process when busy in a loop
body: <p>I'm running a script on my Raspberry. Sometimes happens that the program freezes, so I've to close the terminal and re-run the .py</p>
  <p>So I wanted to &quot;multiprocess&quot; this program. I made two function, the first one does the work, the second one has the job to check the time, and kill the process of the first function in the case the condition is true.</p>
  <p>However I tried to do like so:</p>
  <pre><code>def AntiFreeze():
      print(&quot;AntiFreeze partito\n&quot;)
  
      global stop
      global endtime
      global freq
  
      proc_SPN = multiprocessing.Process(target=SPN(), args=())
      proc_SPN.start()
  
      time.sleep(2)
  
      proc_SPN.terminate()
      proc_SPN.join()
  
  if __name__ == '__main__':
      proc_AF = multiprocessing.Process(target=AntiFreeze(), args=())
      proc_AF.start()
  </code></pre>
  <p>The main function start the &quot;AntiFreeze&quot; function on a process, this one create another process to run the function that will do the Job I want.</p>
  <p><strong>THE PROBLEM (I think):</strong>
  The function &quot;SPN()&quot; (that is the one that does the job) is busy in a very long while loop that calls function in another .py file.
  So when I use <code>proc_SPN.terminate()</code> or <code>proc_SPN.kill()</code> nothing happens... why?</p>
  <p>There is another way to force a process to kill? maybe I've to do two different programs?</p>
  <p>Thanks in advance for help</p>