标签:imp from getc monkey div eve int nal event
from greenlet import greenlet import time def test1(): while True: print(‘----A----‘) g2.switch() time.sleep(0.5) def test2(): while True: print(‘----B----‘) g1.switch() time.sleep(0.5) g1 = greenlet(test1) g2 = greenlet(test2) g1.switch()
import gevent,time from gevent import monkey; monkey.patch_all() def f1(n): for i in range(n): print(gevent.getcurrent(),i) time.sleep(0.1) def f2(n): for i in range(n): print(gevent.getcurrent(),i) time.sleep(0.1) def f3(n): for i in range(n): print(gevent.getcurrent(),i) time.sleep(0.1) # g1 = gevent.spawn(f1,5) # g2 = gevent.spawn(f2,5) # g3 = gevent.spawn(f3,5) # g1.join() # g2.join() # g3.join() gevent.joinall([gevent.spawn(f1,5), gevent.spawn(f2,5), gevent.spawn(f3,5)])
标签:imp from getc monkey div eve int nal event
原文地址:https://www.cnblogs.com/kuraki/p/9642190.html