0

Hi i am trying to run my flask app with one particular function at the same time. For that I am using _thread. But when I start my server function called in _thread.start_new_thread() is called twice. I need to call it just once, any idea where is the problem?

def callPCo():
    requests.get("http://127.0.0.1:5120/pco")

if __name__ == '__main__':

    _thread.start_new_thread(callPCo, ())
    app.run(host = "127.0.0.1", port = "5115", use_reloader=True)
wondergrandma
  • 103
  • 1
  • 12
  • 1
    Does https://stackoverflow.com/questions/43644083/python-thread-running-twice-when-called-once-in-main help? – Larry the Llama Mar 21 '23 at 20:50
  • @LarrytheLlama The answer there says to not use `debug=True`, but they're not doing that. – Barmar Mar 21 '23 at 20:59
  • Yes that will be it Thanks. I am using `use_reloader=True`. It is probably similar to `debug=True`. So when i changed to False it executes just once – wondergrandma Mar 21 '23 at 20:59

0 Answers0