event异步回调

importthreading

importtime

defdo(event):

print('start')

time.sleep(1)

event.set()

print('event set')

event_obj = threading.Event()

t = threading.Thread(target=do,args=(event_obj,))

t.start()

print("no event result")

event_obj.wait()

# for i in range(10):

print("event result")

你可能感兴趣的:(event异步回调)