gevent实现并发

zuiaiqun 2019-12-12

#_author:来童星#date:2019/12/12import geventimport timedef 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),])运行结果:

gevent实现并发

 

相关推荐

CandyGL / 0评论 2016-03-02