You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.3KB

  1. # import asyncio
  2. # import threading
  3. # import time
  4. #
  5. #
  6. # async def print_hello(d):
  7. # print("aaaaaaaaaaa")
  8. # await asyncio.sleep(d)
  9. # print("nnnnnnnnnnnnn")
  10. # return 11
  11. #
  12. # async def print_hello1(d):
  13. # print("ssssssssssssssss")
  14. # await asyncio.sleep(2)
  15. # print("qqqqqqqqqqqqq")
  16. # return 22
  17. # def aa(d):
  18. # loop = asyncio.new_event_loop()
  19. # asyncio.set_event_loop(loop)
  20. # start = time.time()
  21. # aaaa = loop.run_until_complete(asyncio.gather(print_hello(1), print_hello(2)))
  22. # print(aaaa)
  23. # # aa = loop.run_until_complete(asyncio.wait(tasks1))
  24. # # asyncio.gather()
  25. # # print(aa[0].pop().result())
  26. # # asyncio.run(print_hello())
  27. # # asyncio.run(print_hello1())
  28. # # async def main():
  29. # # task = asyncio.create_task(print_hello())
  30. # # task1 = asyncio.create_task(print_hello1())
  31. # # # await task
  32. # # # await task1
  33. # # asyncio.run(main())
  34. # print("ddddddddddddddddddddddd", time.time() - start)
  35. #
  36. # threading.Thread(target=aa, args=(1,)).start()
  37. # # threading.Thread(target=aa, args=(loop, 2)).start()
  38. # # threading.Thread(target=aa, args=(loop, 2)).start()
  39. # # loop.close()
  40. # # loop.close()
  41. # # 打印结果
  42. # # cccccccccccccccccccccc
  43. # # aaaaaaaaaaa
  44. # # nnnnnnnnnnnnn
  45. # # ssssssssssssssss
  46. # # qqqqqqqqqqqqq
  47. # # ddddddddddddddddddddddd
  48. a = lambda x: print(x)
  49. a(1)