【Python】greenlet模块
from greenlet import greenlet
# 可实现切换,但无法检测IO
def eat(name):
print('%s eat 1' % name)
g2.switch('name')
print('%s eat 2' % name)
g2.switch()
def play(name):
print('%s play 1' % name)
g1.switch()
print('%s play 2' % name)
g1.switch()
g1 = greenlet(eat)
g2 = greenlet(play)
g1.switch('egon')