python(greenlet 携程(自动))

# Author: Sooele

from greenlet import greenlet


def test1():
    print(12)   #1
    gr2.switch()
    print(34) #5
    gr2.switch()


def test2():
    print(56) #3
    gr1.switch()
    print(78) #6


gr1 = greenlet(test1) #启动一个携程 #4
gr2 = greenlet(test2)  #2
gr1.switch()

发表评论