Is there an easy way in Python to wait until certain condition is true?

后端 未结 8 1357

I need to wait in a script until a certain number of conditions become true?

I know I can roll my own eventing using condition variables and friends, but I don\'t wa

8条回答
  •  甜味超标
    2020-12-23 21:20

    Here's my Code I used during one of my Projects :

    import time
    def no() :
        if (Condition !!!) :
            it got true
            oh()
        else:
            time.sleep(1) /Don't remove or don't blame me if ur system gets ""DEAD""
            no()
    def oh() :   /Ur main program 
        while True:
            if(bla) :
                .......
                no()
            else :
                time.sleep(1)
                oh()
    
    oh()
    

    Hope it Helps

提交回复
热议问题