41 lines
798 B
Python
41 lines
798 B
Python
from multiprocessing import Process
|
|
import time
|
|
|
|
class Array_Class:
|
|
def __init__(self):
|
|
self.array = []
|
|
|
|
def SetArray(self, parray):
|
|
array = parray
|
|
|
|
def GetArray(self):
|
|
return self.array
|
|
|
|
my_array = Array_Class()
|
|
|
|
|
|
def update_crontab():
|
|
global my_array
|
|
array = []
|
|
time.sleep(5)
|
|
array.append(1)
|
|
my_array.SetArray(array)
|
|
print("set done")
|
|
|
|
def update_based_on_crontab():
|
|
time.sleep(5)
|
|
print(my_array.GetArray())
|
|
|
|
|
|
"""update_crontab()
|
|
update_based_on_crontab()"""
|
|
|
|
if __name__ == "__main__":
|
|
p1 = Process(target= update_crontab, args=())
|
|
p1.start()
|
|
p3 = Process(target= update_based_on_crontab, args=() )
|
|
p3.daemon = True
|
|
p3.start()
|
|
p1.join()
|
|
p3.terminate()
|
|
p1.terminate() |