1

My code looks like this:

app = Flask(__name__)

def target():
    while True:
        time.sleep(10)
        print('ok')

if __name__ == '__main__':
    thread(target = target, args = ()).start()
    app.run()

Why the target function runs twice ?? (I mean, the output is 2 'ok' after every 10 seconds)

davidism
  • 121,510
  • 29
  • 395
  • 339
  • I can't reproduce your issue. It prints only once on my machine. Could you share your dependencies? – Gabio Apr 13 '20 at 12:12
  • 1
    This is related to this: https://stackoverflow.com/questions/25504149/why-does-running-the-flask-dev-server-run-itself-twice/25504196 –  Apr 13 '20 at 12:44

0 Answers0