here is the error detail: http://dev.mysql.com/doc/refman/5.0/en/commands-out-of-sync.html .
The Mysqldb manual offers the following:
Do not share connections between threads. It really is not worth your efforts or mine, and in the end, it can hurt performance, as the MySQL server starts a separate thread for each connection. You can certainly do things like caching in a pool, and transfer these connections one stream at a time. If you allow two threads to use the connection at the same time, the MySQL client library is likely to work and die. You have been warned.
For streaming applications, try using a connection pool. This can be done using the pool module.
Learn more about finding the threadsafety keyword in the MySQLdb Handbook .
source share