Skip to content

Instantly share code, notes, and snippets.

@notsobad
Last active January 3, 2016 10:59
Show Gist options
  • Save notsobad/8452751 to your computer and use it in GitHub Desktop.
Save notsobad/8452751 to your computer and use it in GitHub Desktop.

参考:

gevent的所有greenlets是在操作系统的同一个进程、同一个线程内运行,所以一些阻塞的操作需要被替换为不阻塞的,这也就是monkey.patch_all()的作用。

spawn一个greenlet之后,它并不立即运行,gevent.sleep() 会yield到下一个greenlet。

gevent.joinall()会等待所有greenlets完成才退出。

通过gevent.Greenlet创建的greenlet并不会自动运行,需要调用它的start方法。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment