'''
利用greenlet实现多个任务的切换
'''
from greenlet import greenlet
def f1():
print('1')
gr2.switch()
print('3')
def f2():
print('2')
gr1.switch()
print('4')
gr1 = greenlet(f1)
gr2 = greenlet(f2)
gr1.switch()
'''
利用greenlet实现多个任务的切换
'''
from greenlet import greenlet
def f1():
print('1')
gr2.switch()
print('3')
def f2():
print('2')
gr1.switch()
print('4')
gr1 = greenlet(f1)
gr2 = greenlet(f2)
gr1.switch()
转载于:https://www.cnblogs.com/victorstudy/p/11425907.html