greenlet示例
greenlet微线程,允许在线程中手动切换
示例1,线程切换
from greenlet import greenlet
def test1(x,y):
z = gr2.switch(x+y)
print(z)
def test2(u):
print(u)
gr1.switch(42)
gr1 = greenlet(test1)
gr2 = greenlet(test2)
gr1.switch(hello,'world')
gr1和gr2是两个greenlet线程,使用gr1.switch(..)启动gr1,gr1执行test1,切换到gr2,g