[Solved] infinite while loop python


Your second while loop has no break point!!!
Your first while loop runs until it detects motion and then enters the second loop, and your second loop runs forever.
If you want both loops to work simultaneously then you should use threads!!!
If not then make a break point in second loop.

Simple example:

import time
count=0
count2=0
while True:    #starting first loop 
    count+=1 # counting to 100 to start second loop
    if count==100:
        print("its 100 entering second loop")
        time.sleep(1)
        while True: # entering second loop
            count2+=1 #counting to 100 to exit second loop 
            if count2==100:
                print("its 100 exitin second loop")
                time.sleep(1)
                count=0
                count2=0
                break # exiting second loop this is the break point

2

solved infinite while loop python