title: Control running Python Process (multiprocessing)
body: <p>I have yet another question about Python multiprocessing.
  I have a module that creates a Process and just runs in a while True loop.
  This module is meant to be enabled/disabled from another Python module.
  That other module will import the first one once and is also run as a process.</p>
  
  <p>How would I better implement this?</p>
  
  <p>so for a reference:</p>
  
  <pre><code>#foo.py
  
  def foo():
    while True:
      if enabled:
        #do something
  
  p = Process(target=foo)
  p.start()
  </code></pre>
  
  <p>and imagine second module to be something like that:</p>
  
  <pre><code>#bar.py
  import foo, time
  
  def bar():
    while True:
      foo.enable()
      time.sleep(10)
      foo.disable()
  
  Process(target=bar).start()
  </code></pre>
  
  <p>Constantly running a process checking for condition inside a loop seems like a waste, but I would gladly accept the solution that just lets me set the <code>enabled</code> value from <strong>outside</strong>.
  Ideally I would prefer to be able to terminate and restart the process, again from <strong>outside</strong> of this module.
  From my understanding, I would use a Queue to pass commands to the Process. If it is indeed just that, can someone show me how to set it up in a way that I can add something to the queue from a different module.</p>
  
  <p>Can this even be easily done with Python or is it time to abandon hope and switch to something like C or Java</p>