title: Change global variable in a module from a function defined in another module
body: <p>I have a module with a main function that runs a loop while a flag is true.
  In the loop, there is a call to a function defined in another module that check a conditions and should stop the main loop if it's True.</p>
  
  <p>The code is:</p>
  
  <p><strong>main.py</strong>    </p>
  
  <pre><code>import other
  
  isRunning = True
  def shutdown():
      global isRunning
      isRunning = False
  
  def main():
      while isRunning:
          # some logic here
          other.check()
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p><strong>other.py</strong></p>
  
  <pre><code>import main
  
  def check():
      someCondition = #some logic to check the condition
      if someCondition:
          main.shutdown()
  </code></pre>
  
  <p>The code is run launching the <code>main.py</code> file.</p>
  
  <p>The issue is that when <code>other.check()</code> is called in the loop, the <code>main.shutdown()</code> function is called but the main loop keeps running. In the main loop the <code>isRunning</code> variable is always <code>True</code>, but I was expecting it to become <code>False</code> after being set in the <code>main.shutdown()</code> function.
  Why is this happening? What am I missing?</p>
  
  <p>I could refactor the code to mange the exit from the loop in a smarter way, but I am interested to know if there is a solution keeping this kind of code structure.</p>