From bd575142e20596a71e8f3a6cbb2596685485cbb1 Mon Sep 17 00:00:00 2001 From: "A. Jesse Jiryu Davis" Date: Fri, 22 Mar 2013 21:25:39 -0400 Subject: [PATCH] Update Tornado and Twisted recommendations --- doc/faq.rst | 38 ++++++-------------------------------- doc/tools.rst | 3 --- 2 files changed, 6 insertions(+), 35 deletions(-) diff --git a/doc/faq.rst b/doc/faq.rst index 5ca37f2f0..b6cbd8880 100644 --- a/doc/faq.rst +++ b/doc/faq.rst @@ -38,41 +38,15 @@ Starting with version 2.2 PyMongo supports Python 3.x where x >= 1. See the Does PyMongo support asynchronous frameworks like Gevent, Tornado, or Twisted? ------------------------------------------------------------------------------ -The only async framework that PyMongo fully supports is `Gevent -`_. -Currently there is no great way to use PyMongo in conjunction with `Tornado -`_ or `Twisted `_. -PyMongo provides built-in connection pooling, so some of the benefits of those -frameworks can be achieved just by writing multi-threaded code that shares a -:class:`~pymongo.mongo_client.MongoClient`. +PyMongo fully supports :doc:`Gevent `. -There are asynchronous MongoDB drivers in Python: `Motor for Tornado -`_ and `TxMongo for Twisted +To use MongoDB with `Tornado `_ see the +`Motor `_ project. + +For `Twisted `_, see `TxMongo `_. Compared to PyMongo, -however, these projects are less stable, lack features, and are less actively -maintained. - -It is possible to use PyMongo with Tornado, if some precautions are taken to -avoid blocking the event loop: - -- Make sure all MongoDB operations are very fast. Use the - `MongoDB profiler `_ - to watch for slow queries. - -- Create a single :class:`~pymongo.mongo_client.MongoClient` instance for your - application in your startup code, before starting the IOLoop. - -- Configure the :class:`~pymongo.mongo_client.MongoClient` with a short - ``socketTimeoutMS`` so slow operations result in a - :class:`~pymongo.errors.TimeoutError`, rather than blocking the loop and - preventing your application from responding to other requests. - -- Start up extra Tornado processes. Tornado is typically deployed with one - process per CPU core, proxied behind a load-balancer such as - `Nginx `_ or `HAProxy `_; - when using Tornado with a blocking driver like PyMongo it's recommended you - start two or three processes per core instead of one. +TxMongo is less stable, lack features, and is less actively maintained. What does *OperationFailure* cursor id not valid at server mean? ---------------------------------------------------------------- diff --git a/doc/tools.rst b/doc/tools.rst index 5b504e0f6..3f30f8310 100644 --- a/doc/tools.rst +++ b/doc/tools.rst @@ -113,9 +113,6 @@ These are alternatives to PyMongo. * `Motor `_ is a full-featured, non-blocking MongoDB driver for Python Tornado applications. -* `asyncmongo `_ is an asynchronous library - for accessing mongo which is built on the Tornado IOLoop, but doesn't support - to replica sets. * `TxMongo `_ is an asynchronous Python driver for MongoDB, although it is not currently recommended for production use.