greenlet

#_author:来童星
#date:2019/12/12
from greenlet import greenlet
def test1():
print(12)
gr2.switch()
print(34)
gr2.switch()
def test2():
print(56)
gr1.switch()
print(78)
gr1 = greenlet(test1)# <greenlet.greenlet object at 0x00000293A37F4048>
gr2 = greenlet(test2)
gr1.switch()
运行结果:
12
56
34
78
56
78
上一篇:python中asyncio异步编程


下一篇:网络编程之协程——greenlet模块