concurrent

Coroutine[1] #

协程 #

  • 无栈协程 -> asyncio
  • 有栈协程 -> gevent

asyncio [3] #

  • eventloop
    event task注册
  • 封装task
    asyncio.create_task 所有权
  • await 关键字 [2]
    • 用于等待一个可等待对象(如协程、Future、Task)的结果。
      用于等待一个可等待对象的结果,协程在此暂停,直到结果返回。
    • 当协程遇到 await,它会暂停执行,等待结果返回后继续。

多线程 #

  • 线程池 concurrent.futures.ThreadPoolExecutor
    executor.submit()

多进程与多线程[10] #

参考 #

Coroutine #

  1. Coroutine
  2. asyncio_basics git
  3. async_pattern.ipynb git

多进程与多线程 #

10.多进程与多线程