1. greenlet
自行执行的微线程
https://greenlet.readthedocs.io/en/latest/greenlet.html
2. 终端安装
pip install greenlet
3. 举个栗子
import time from greenlet import greenlet def work1(): while True: print("executing work1......") time.sleep(0.5) g2.switch() def work2(): while True: print("executing work2......") time.sleep(0.5) g1.switch() if __name__ == '__main__': g1 = greenlet(work1) g2 = greenlet(work2) g1.switch()
标签:__,协程,g1,python,switch,greenlet,work1,work2 From: https://www.cnblogs.com/baxianhua/p/17248269.html