Click here to Skip to main content
15,567,994 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Python
def a1(request):
    if request.method == "POST":
        add = request.POST['addition']
        while True:
            add = add + 1
            print(add)
            time.sleep(2)
    return render(request, blog/finished.html)
        
def a2(request):
    if request.method == "POST":
        check = request.POST['checking']
        while True:
            print(check)
            print("second function: ",check)
            time.sleep(2)        
    return render(request, blog/finished.html)


What I have tried:

Quote:
I have called the first "a1" function and it's starts running in the loop and when I called the second "a2" function, the first "a1" function supposed to stop and second function has to start running, but the two functions are running parallelly. I need to stop the first function when the second function is called. Please help
Posted
Comments
Maciej Los 3-Nov-21 5:37am    
Yes, you have defined 2 functions, but you did NOT show us the way you call them.
Dave Kreskowiak 3-Nov-21 8:03am    
OK, so how are you stopping A1 from running? 'cause, it'll run forever on its own, same with A2.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900