1

I'm trying to call a function where I'm trying to do simple operation in the target function but I saw that thread is triggering the same function multiple times

def __init_application():
    app = FastAPI(title="Test", version="0.1")
    feedback_ack = Thread(target=test_ack)
    feedback_ack.start()
    return app
api_app = __init_application()



def test_ack():
    var = 0
    while True:
        if var>5:
            break
        var+=1
        print(var)

But as this thread is calling this multiple times, it is printing weirdly.

So what could be the solution for this?

praveen jp
  • 65
  • 10
  • 1
    That code, as written, will not run due to **NameError: name 'test_ack' is not defined** What exactly is your problem? – DarkKnight Feb 02 '23 at 12:39

0 Answers0