编程语言
首页 > 编程语言> > python3 greenlet模块

python3 greenlet模块

作者:互联网

pip install greenlet

# -*- coding: utf-8 -*-
from greenlet import greenlet


def func1():
    print("func1 first")
    gr2.switch()
    print("func2 second")
    gr2.switch()


def func2():
    print("func2 first")
    gr1.switch()
    print("func2 second")


gr1 = greenlet(func1)
gr2 = greenlet(func2)
gr1.switch()

# func1 first
# func2 first
# func2 second
# func2 second

 

标签:func2,func1,switch,second,greenlet,模块,print,python3
来源: https://www.cnblogs.com/lilyxiaoyy/p/11037234.html