擅长:python、mysql、java
<p>我已经将Tornado的聊天示例转换为在<a href="http://www.gevent.org/" rel="nofollow noreferrer">gevent</a>上运行。看看<a href="http://chat.gevent.org" rel="nofollow noreferrer">the live demo here</a>和<a href="http://blog.gevent.org/2009/10/10/simpler-long-polling-with-django-and-gevent/" rel="nofollow noreferrer">the explanation and source code here</a>。</p>
<p>它使用轻量级用户级线程(<a href="http://codespeak.net/py/0.9.2/greenlet.html" rel="nofollow noreferrer">greenlets</a>),在速度/内存使用方面与Tornado相当。但是,代码很简单,您可以在处理程序中调用sleep()和urlopen(),而不阻塞整个过程,并且可以生成执行相同操作的长时间运行的作业。在幕后,应用程序是异步的,由一个用C(<a href="http://www.monkey.org/~provos/libevent/" rel="nofollow noreferrer">libevent</a>)编写的事件循环提供动力。</p>
<p>你可以阅读<a href="http://www.gevent.org/intro.html" rel="nofollow noreferrer">introduction here</a>。</p>