Skip to content

Commit 0530a06

Browse files
committed
Merge branch 'master' into py3k
Conflicts: pymongo/connection.py pymongo/database.py pymongo/master_slave_connection.py test/test_database.py test/test_pooling.py test/test_thread_util.py tools/auto_reconnect_test.py
2 parents 94c0818 + 0fe4b29 commit 0530a06

17 files changed

+313
-650
lines changed

README.rst

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,28 @@ PyMongo
66

77
About
88
=====
9-
The PyMongo distribution contains tools for interacting with the Mongo database from Python.
10-
The ``pymongo`` package is a native Python driver for the Mongo database. The ``gridfs``
11-
package is a `gridfs <http://www.mongodb.org/display/DOCS/GridFS+Specification>`_
9+
10+
The PyMongo distribution contains tools for interacting with the Mongo
11+
database from Python. The ``pymongo`` package is a native Python
12+
driver for the Mongo database. The ``gridfs`` package is a `gridfs
13+
<http://www.mongodb.org/display/DOCS/GridFS+Specification>`_
1214
implementation on top of ``pymongo``.
1315

1416
Installation
1517
============
16-
If you have `setuptools <http://peak.telecommunity.com/DevCenter/setuptools>`_ installed you should be able to do **easy_install pymongo** to install PyMongo. Otherwise you can download the project source and do **python setup.py install** to install.
18+
19+
If you have `setuptools
20+
<http://peak.telecommunity.com/DevCenter/setuptools>`_ installed you
21+
should be able to do **easy_install pymongo** to install
22+
PyMongo. Otherwise you can download the project source and do **python
23+
setup.py install** to install.
1724

1825
Dependencies
1926
============
20-
The PyMongo distribution has been tested on Python 2.x, where x >= 3. On Python 2.3 the optional
21-
C extension will not be built. This will negatively affect performance, but everything should still work.
27+
28+
The PyMongo distribution is supported and tested on Python 2.x, where
29+
x >= 4. PyMongo versions <= 1.3 also supported Python 2.3, but that is
30+
no longer supported. If you need to use Python 2.3 please contact us.
2231

2332
Additional dependencies are:
2433

@@ -63,10 +72,18 @@ u'x_1'
6372

6473
Documentation
6574
=============
66-
You will need sphinx_ installed to generate the documentation. Documentation can be generated by running **python setup.py doc**. Generated documentation can be found in the *doc/build/html/* directory.
75+
76+
You will need sphinx_ installed to generate the
77+
documentation. Documentation can be generated by running **python
78+
setup.py doc**. Generated documentation can be found in the
79+
*doc/build/html/* directory.
6780

6881
Testing
6982
=======
70-
The easiest way to run the tests is to install `nose <http://somethingaboutorange.com/mrl/projects/nose/>`_ (**easy_install nose**) and run **nosetests** or **python setup.py test** in the root of the distribution. Tests are located in the *test/* directory.
83+
84+
The easiest way to run the tests is to install `nose
85+
<http://somethingaboutorange.com/mrl/projects/nose/>`_ (**easy_install
86+
nose**) and run **nosetests** or **python setup.py test** in the root
87+
of the distribution. Tests are located in the *test/* directory.
7188

7289
.. _sphinx: http://sphinx.pocoo.org/

doc/api/pymongo/connection.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
.. automodule:: pymongo.connection
55
:synopsis: Tools for connecting to MongoDB
66

7-
.. autoclass:: pymongo.connection.Connection([host='localhost'[, port=27017[, pool_size=1[, auto_start_request=True[, timeout=1.0[, slave_okay=False[, network_timeout=None]]]]]]])
7+
.. autoclass:: pymongo.connection.Connection([host='localhost'[, port=27017[, pool_size=None[, auto_start_request=None[, timeout=None[, slave_okay=False[, network_timeout=None]]]]]]])
88

9-
.. automethod:: paired(left[, right=('localhost', 27017)[, pool_size=1[, auto_start_request=True]]])
9+
.. automethod:: paired(left[, right=('localhost', 27017)[, pool_size=None[, auto_start_request=None]]])
1010
.. automethod:: disconnect
1111

1212
.. describe:: c[db_name] || c.db_name

doc/api/pymongo/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,4 @@ Sub-modules:
2929
son
3030
son_manipulator
3131
json_util
32-
thread_util
3332
cursor_manager

doc/api/pymongo/thread_util.rst

Lines changed: 0 additions & 6 deletions
This file was deleted.

doc/faq.rst

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,36 @@ Frequently Asked Questions
55

66
Is PyMongo thread-safe?
77
-----------------------
8+
89
PyMongo is thread-safe and even provides built-in connection pooling
9-
for threaded applications. See the documentation for
10-
:class:`~pymongo.connection.Connection`, notably the `pool_size`
11-
parameter.
10+
for threaded applications.
11+
12+
How does connection pooling work in PyMongo?
13+
--------------------------------------------
14+
15+
Every :class:`~pymongo.connection.Connection` instance has built-in
16+
connection pooling. Each thread gets its own socket reserved on its
17+
first operation. Those sockets are held until
18+
:meth:`~pymongo.connection.Connection.end_request` is called by that
19+
thread, or :meth:`~pymongo.connection.Connection.disconnect` is called
20+
by any thread, or the thread dies.
21+
22+
Calling :meth:`~pymongo.connection.Connection.end_request` allows the
23+
socket to be returned to the pool, and to be used by other threads
24+
instead of creating a new socket. Judicious use of this method is
25+
important for applications with many threads or with long running
26+
threads that make few calls to PyMongo operations.
1227

1328
How can I use PyMongo with an asynchronous socket library like `twisted <http://twistedmatrix.com/>`_?
1429
------------------------------------------------------------------------------------------------------
30+
1531
Currently there is no great way to use PyMongo in conjunction with
1632
asynchronous socket frameworks like `twisted
1733
<http://twistedmatrix.com/>`_ or `tornado
18-
<http://www.tornadoweb.org/>`_. One way to get the same benefits those
19-
frameworks provide using PyMongo is to write multi-threaded code and
20-
use PyMongo's built in connection pooling.
34+
<http://www.tornadoweb.org/>`_. PyMongo provides built-in connection
35+
pooling, so some of the benefits of those frameworks can be achieved
36+
just by writing multi-threaded code that shares a
37+
:class:`~pymongo.connection.Connection`.
2138

2239
There is work in progress towards creating an `asynchronous Python
2340
driver <http://github.com/fiorix/mongo-async-python-driver>`_ for

pymongo/collection.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ def remove(self, spec_or_object_id=None, safe=False):
302302
The `spec_or_object_id` parameter is now optional. If it is
303303
not specified *all* documents in the collection will be
304304
removed.
305-
306305
.. versionadded:: 1.1
307306
The `safe` parameter.
308307
"""
@@ -656,11 +655,11 @@ def group(self, key, condition, initial, reduce, finalize=None,
656655
command instead of in an eval - this option is deprecated and
657656
will be removed in favor of running all groups as commands
658657
659-
.. versionchanged:: 1.3
660-
The `command` argument now defaults to ``True`` and is deprecated.
661658
.. versionchanged:: 1.3+
662659
The `key` argument can now be ``None`` or a JavaScript function,
663660
in addition to a :class:`list` of keys.
661+
.. versionchanged:: 1.3
662+
The `command` argument now defaults to ``True`` and is deprecated.
664663
"""
665664
if not command:
666665
warnings.warn("eval-based groups are deprecated, and the "

0 commit comments

Comments
 (0)