title: Changing a variable from main thread in threaded-function from other module in python
body: <p>I am trying to use multithreading in python an I would like to access a variable, defined in a main thread inside a function from other module, which is called in a separate thread from the main thread.</p>
  
  <p>worker_module:</p>
  
  <pre><code>def function_foo():
     do_some_heavy_computing()
     shared_set.add(value)
  </code></pre>
  
  <p>Main module:</p>
  
  <pre><code>from threading import Thread
  import worker_module     
  
  shared_set = set()
  
  if __name__ == '__main__':
      worker_thread = Thread(target=worker_module.function_foo,args=())
      worker_thread.start()
  
      # go on and make some progress without waiting
  </code></pre>
  
  <p>I want to be able, to add some value to the shared set without waiting for <em>function_foo</em> to finish. I am unsure how to "share" the set between the two threads and functions in different modules.</p>