使用gevent实现mysql并发时,每个greenlet应该独享一个mysql连接,否则,不同的greenlet之间会相互影响。
ultramysql doesn‘t allow you to make multiple queries on the same mysql connection, it just makes it async friendly. So you will either need a new mysql connection for each greenlet or use locking primitives to makes sure only one greenlet is using the connection at a time.
https://stackoverflow.com/questions/13308446/how-to-insert-async-into-mysql-using-python
原文:https://www.cnblogs.com/buxizhizhoum/p/9007477.html