title: get out of infinite loop when using exec to excute infinite loop in python
body: <p>I have a program :</p>
  
  <pre><code>def mid(a, b):
      if a == 0:
          print(b)
          r = b
          r = r + 1
          return r
      while b != 0:
          if a &gt; b:
              a = a - b
  
  
      print(a)
      r = a
      return r
  </code></pre>
  
  <p>So I wanna use exec function to execute this program, like that :</p>
  
  <pre><code>exec('%s(*(tests[i]))' % funName)
  </code></pre>
  
  <p>with funName is "mid", tests[i] = (3,2) so when (a,b) = (3,2) the while loop become infinite loop and I can't get out of this loop at exec . Any suggest for me ? </p>