title: Using Global variables in Threads in Python
body: <p>I am in a situation where i want to put a thread in a loop depending on a variable which is being changed in one of the called function in the thread.Here is what i want.</p>
  
  <pre><code>error= 0
  
  while( error = 0)
      run_thread = threading.Thread(target=self.run_test,args=(some arguments))
  
  if ( error = 0)
      continue
  else:
      break
  </code></pre>
  
  <p>Now run test calls a function say A and A calls B and B calls C.</p>
  
  <pre><code>def A()
        B()
  def B()
       c()
  
  def c()
      global error
      error = 1
  </code></pre>
  
  <p>This is what i want to do but i cant work this out. If i try to print error i get an error in code.</p>
  
  <p>Can anybody please help me on this?</p>
  
  <p>i am a beginner and need to get over this</p>