Answers for "python wait until finish running"

3

python wait until

import time
def waitUntil(condition, output): #defines function
    wU = True
    while wU == True:
        if condition: #checks the condition
            output
            wU = False
        time.sleep(60) #waits 60s for preformance

waitUntil(Cookies >= 0, eatCookies()) #runs function (output MUST be another function)
Posted by: Guest on November-19-2020
0

python wait until all threads finish

import threading
import time

def loop1_10(timeSleep):
    for i in range(1, 11):
        time.sleep(timeSleep)
        print("timeSleep:"+str(timeSleep)+": ",i)

t1 = threading.Thread(target=loop1_10, args=[1])
t2 = threading.Thread(target=loop1_10, args=[2])
t3 = threading.Thread(target=loop1_10, args=[0.5])

t1.start()
t2.start()
t3.start()

t1.join()
t2.join()
t3.join()

print("All thread is done !!!")
Posted by: Guest on July-24-2021

Python Answers by Framework

Browse Popular Code Answers by Language