gevent实现并发
#_author:来童星
#date:2019/12/12
import gevent
import time
def func1():
print('\033[31;1mfun1 starting...\033[0m',time.ctime())
gevent.sleep(2)
print('\033[31;1mfun1 ending...\033[0m',time.ctime())
def func2():
print('\033[32;1mfun2 starting...\033[0m',time.ctime())
gevent.sleep(1)
print('\033[32;1mfun2 ending...\033[0m',time.ctime())
gevent.joinall([
gevent.spawn(func1),
gevent.spawn(func2),
])
运行结果: