by amix · 16y ago · 0 comments
If you want to use non-blocking in Python then using something like Twisted is an option since Twisted implements most things in an non-blocking way, but Twisted hasn't really gained that much traction in the many years of its existence.
So yes if you do a hello world benchmark then you get a 4x speed improvement, but if you do any library calls (such as doing a MySQL query) you will get decreased perfomance since the MySQL Python library is blocking (and most other libraries are blocking as well)...
Because it's using event's it has not blocking IO. But is limited when the tasks are CPU bound
There's also a mysql driver for gevent implemented as an extension: http://github.com/mthurlin/gevent-MySQL
A while back we avoided gevent because of this but used eventlet instead because they had a native MySQL patched driver.
Performance on the pure connector was just too bad.
Have you tried gevent-MySQL? It's written in Cython and as far as I know is fast.