import asyncio
async def func(event):
print(1)
event.set()
await asyncio.sleep(3)
await event.wait()
print('1')
async def main():
event = asyncio.Event()
task = asyncio.create_task(func(event))
await event.wait()
print('2332321')
event.set()
await task
asyncio.run(main())
import threading
import time
def func():
print(1)
time.sleep(3)
print('1')
threading.Thread(target = func).start()
print('2332321')
import multiprocessing
import time
def func(event1, event2):
print(1)
event1.set()
time.sleep(3)
event2.wait()
print('1')
def main():
event1 = multiprocessing.Event()
event2 = multiprocessing.Event()
process = multiprocessing.Process(target=func, args=(event1, event2))
process.start()
event1.wait()
print('2332321')
event2.set()
process.join()
if __name__ == '__main__':
main()