title: inheriting global variable outside of flask app
body: <p>I have an app where I'm monitoring the state of a switch while presenting a url for a user to activate another switch:</p>
  
  <pre><code>door="closed"
  def switch():
    global door
    #handle GPIO SETUP
    button_state = GPIO.input(#pin)
    if button_state == True:
      if door=="closed":
        door="open"
    if button_state == False:
      door="closed"
  
  def door_loop():
    while True:
      switch()
      #printing door here returns either open or closed
      time.sleep(1);
  
  @app.route("/click", methods=['GET','POST'])
    def clicky():
      command = request.data
      if command:
        #turn other switch on
  
    return json.dumps({'is_open':door})
  
  
  if __name__ == '__main__':
    p = Process(target=door_loop)
    p.start()
  
    app.run(
      host="0.0.0.0",
      port=int("5000"),
      debug=True
    )
    p.join()
  </code></pre>
  
  <p>If I print out <code>door</code> after the function call to <code>switch()</code> I get the expected output when the door opens or closes (when I push the switch, I see "open" when I let it go, I see "closed"). But when I visit <a href="http://myapp.com/click" rel="nofollow noreferrer">http://myapp.com/click</a> I get <code>{'is_open':'closed'}</code> no matter what the state of the switch is. Is there something that prevents flask from inheriting the modified global variable from the other process?</p>