我有两个函数,每个函数都希望以不同的延迟循环,因此我使用线程。如何在function2中使用value_function1(在function1中计算)?
def function1():
while True:
value_function1 = #gets value from API
time.sleep(60)
def function2():
while True:
#want to use the value_function1 here the last time it was calculated in function1
time.sleep(10)
thread_function1 = threading.Thread(target=function1)
thread_function1.start()
thread_function2 = threading.Thread(target=function2)
thread_function2.start()