from gevent import monkey;monkey.patch_all() import gevent import time def eat(name): print('%s eat 1' % name) time.sleep(3) print('%s eat 2' % name) def play(name): print('%s play 1' % name) time.sleep(4) print('%s play 2' % name) g1=gevent.spawn(eat,'egon') g2=gevent.spawn(play,'alex') # time.sleep(5) # g1.join() # g2.join() gevent.joinall([g1,g2])
相关文章
- 03-16gevent监测单线程下的io进行切换