title: Multithreading/Multiprocessing in Python 3.4 web app for Azure
body: <p>I'm working on writing a Python web app with Flask using Azure to host. I need to do some background work. When I test the app locally, everything works great. However, as soon as I push the update to Azure, it stops functioning. Right now, I have a <code>multithreading.Process</code> set up, and based on the log files, Azure isn't starting another process. Here is the relevant parts of my code:</p>
  <pre><code>#task queue and comm pipes
  tasks = Queue()
  parent_pipe, child_pipe = Pipe()
  
  def handle_queue_execution(tasks, pipe):
      logging.info(&quot;starting task queue handler&quot;)
      while True:
          if pipe.recv():
              logging.debug(&quot;preparing to get task from queue&quot;)
              task = tasks.get()
              args = tasks.get()
              logging.debug(&quot;executing task %s(%s)&quot;, get_fn_name(task), clean_args(args))
              task(args)
              logging.debug(&quot;task %s(%s) executed successfully&quot;, get_fn_name(task), clean_args(args))
  
  queue_handler = Process(target=handle_queue_execution, args=(tasks, child_pipe,))
  queue_handler.daemon = True
  
  if __name__ == '__main__':
      queue_handler.start()
  </code></pre>
  <p>There are a few semi-related questions I have on this:</p>
  <h1>1) Why won't Azure start another process?</h1>
  <p>You'll note that the handle_queue_execution function begins with a logger call. That message doesn't appear in the log file when hosted on Azure, nor do the queued tasks appear to execute. Again, both aspects of this work as expected when running on localhost.</p>
  <h1>2) Is there a better way?</h1>
  <p>I'm fairly new to both Python and Azure, so if there's a better way to do this type of task handling, I'm open to hear about it. I've looked into using something like Celery, but I can't figure out how to set it up, and I'd prefer to make my own implementation as I'm learning these new skills.</p>
  <p>Thanks very much.</p>