In my talk on Python concurrency, I talked about the multiple different approaches to asynchronous network programming in the Python world. I showed Twisted and Tornado Web, and then I compared them to stackless Python and gevent. Toward the end of the talk, I covered how MySQL plays into all this.
In the Python world, we usually use a MySQL driver that is a Python binding to a low-level driver written in C. The low-level driver written in C isn't written to use Python's socket module in any way. In fact, it has nothing to do with Python. Hence, it's impossible to take Twisted or Tornado Web and have them make the low-level driver behave asynchronously.
That's a problem. If you go to all the trouble of making your code asynchronous, it sucks to have one request that is held up on a long query block all the requests in your process. People handle this in different ways.
The Twisted guys can put the MySQL driver on its own thread. You might have 100 requests being handled by Twisted, and 10 threads devoted to MySQL connections.
The Tornado Web guys (from what I can tell) handle it differently. They allow MySQL queries to block the entire process. However, they compensate in two ways. They lean heavily on their asynchronous web client wherever possible. They also make use of multiple Python processes. Hence, if you're handling 500 simultaneous request, you might use nginx to split them among 10 different Tornado Web processes. Each process is handling 50 simultaneous requests. If one of those requests needs to make a call to the database, only 50 (instead of 500) requests are blocked.
At lolapps, they use Tornado Web too (at least for certain things). Their approach is to lean heavily on memcached and avoid talking to MySQL in real time whenever possible.
At IronPort, Sam Rushing (who's now working on a cool project called Irken) wrote a custom MySQL driver in Python. It was built with his proprietary version of stackless Python in mind, and hence it was asynchronous.
I think the same thing should be possible in the gevent world. MySQL Connector/Python is a MySQL driver written in pure Python. Since gevent permits you to use asynchronous networking APIs without forcing you to use continuation-passing style, it's possible that gevent could be used with MySQL Connector/Python to make your MySQL queries asynchronous too. Thank goodness for greenlet!
This is a topic I feel strongly about. I remember in the early days of Java, the JVM supported kernel threads as well as green threads. Some people would use green threads and then do multi-threaded programming with blocking socket APIs. What a lot of them didn't realize is that with green threads, if you call a synchronous networking API, you're blocking all your threads, not just one of them. Similarly, I feel strongly that if you're going to all the trouble of using an asynchronous web framework, your MySQL queries should be asynchronous too.