1. 程式人生 > >Python 協程 greenlet

Python 協程 greenlet

port test imp pre int switch from def st2

from greenlet import greenlet
def test1():
print("a")
gr2.switch()
print("b")
gr2.switch()
def test2():
print("c")
gr1.switch()
print("d")
gr1 = greenlet(test1)
gr2=greenlet(test2)
gr1.switch()

Python 協程 greenlet