from greenlet import greenlet
def test1():
print('12')
gr2.switch() #切换到gr2
print('34')
gr2.switch()
def test2():
print('56')
gr1.switch()
print('78')
gr1 = greenlet(test1) #创建一个test1的协程
gr2 = greenlet(test2) #创建一个test2的协程
gr1.switch() #手动切换到gr1
from greenlet import greenlet
def test1():
print('12')
gr2.switch() #切换到gr2
print('34')
gr2.switch()
def test2():
print('56')
gr1.switch()
print('78')
gr1 = greenlet(test1) #创建一个test1的协程
gr2 = greenlet(test2) #创建一个test2的协程
gr1.switch() #手动切换到gr1