[i=s] 本帖最后由 jieforest 于 2012-7-11 20:23 编辑
Tornado is a popular asynchronous Python web server, and MongoDB a widely used non-relational database. Alas, to connect to MongoDB from a Tornado app requires a tradeoff: You can either use PyMongo and give up the advantages of an async web server, or use AsyncMongo, which is non-blocking but lacks key features.
I decided to fill the gap by writing a new async driver called Motor (for "MOngo + TORnado"), and it's reached the public alpha stage. Please try it out and tell me what you think. I'll maintain a homepage for it here, including basic documentation.
Status
Motor is alpha. It is certainly buggy. Its implementation and possibly its API will change in the coming months. I hope you'll help me by reporting bugs, requesting features, and pointing out how it could be better.
Advantages
Two good projects, AsyncMongo and APyMongo, took the straightforward approach to implementing an async MongoDB driver:
they forked PyMongo and rewrote it to use callbacks. But this approach creates a maintenance headache: now every improvement to PyMongo must be manually ported over.
Motor sidesteps the problem. It uses a Gevent-like technique to wrap PyMongo and run it asynchronously, while presenting a classic callback interface to Tornado applications.
This wrapping means Motor reuses all of PyMongo's code and, aside from GridFS support, Motor is already feature-complete. Motor can easily keep up with PyMongo development in the future.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/301743/viewspace-735212/
,如需转载,请注明出处,否则将追究法律责任。