|
- # import asyncio
- # import threading
- # import time
- #
- #
- # async def print_hello(d):
- # print("aaaaaaaaaaa")
- # await asyncio.sleep(d)
- # print("nnnnnnnnnnnnn")
- # return 11
- #
- # async def print_hello1(d):
- # print("ssssssssssssssss")
- # await asyncio.sleep(2)
- # print("qqqqqqqqqqqqq")
- # return 22
- # def aa(d):
- # loop = asyncio.new_event_loop()
- # asyncio.set_event_loop(loop)
- # start = time.time()
- # aaaa = loop.run_until_complete(asyncio.gather(print_hello(1), print_hello(2)))
- # print(aaaa)
- # # aa = loop.run_until_complete(asyncio.wait(tasks1))
- # # asyncio.gather()
- # # print(aa[0].pop().result())
- # # asyncio.run(print_hello())
- # # asyncio.run(print_hello1())
- # # async def main():
- # # task = asyncio.create_task(print_hello())
- # # task1 = asyncio.create_task(print_hello1())
- # # # await task
- # # # await task1
- # # asyncio.run(main())
- # print("ddddddddddddddddddddddd", time.time() - start)
- #
- # threading.Thread(target=aa, args=(1,)).start()
- # # threading.Thread(target=aa, args=(loop, 2)).start()
- # # threading.Thread(target=aa, args=(loop, 2)).start()
- # # loop.close()
- # # loop.close()
- # # 打印结果
- # # cccccccccccccccccccccc
- # # aaaaaaaaaaa
- # # nnnnnnnnnnnnn
- # # ssssssssssssssss
- # # qqqqqqqqqqqqq
- # # ddddddddddddddddddddddd
- a = lambda x: print(x)
- a(1)
|