* RSState, Member, and MovingAverage are now immutable
* In refresh(), try up members before down ones
* A test_ha fixup (clear process-list after killing them in each test, so we don't re-kill previous tests' processes)
This change adds two new top level classes, MongoClient
and MongoReplicaSetClient. They work almost exactly the
same as Connection and ReplicaSetConnection with a few
differences:
1. These connection objects awknowledge write operations by default.
2. The network_timeout parameter is gone, use socketTimeoutMS instead.
3. auto_start_request defaults to False.
Default acknowledged write operation will be the biggest change for
most users. Using MongoClient and MongoReplicaSetClient you no longer
have to pass safe=True to a write method (save, update, insert, remove)
to request an acknowledgement from the server.
Connection and ReplicaSetConnection are now deprecated but retain their
previous behavior. This should not be a backward breaking change.
Replace the 'mongo' dict with a Member object everywhere in ReplicaSetConnection.
A handful of commands obey read preferences; most are always sent to primary.
Track a 5-sample moving average of each replica set member's ping time.
Connection detects whether it's connected to primary, secondary, or mongos.
Note: In CPython the monitor is no longer a daemon thread. This means that
care must be taken in the interactive shell and simple scripts to set
ReplicaSetConnection references to None so the monitor dies.
The monitor is still a daemon thread in Jython and PyPy.
Big change to PyMongo connection pooling:
* While we still allocate a socket per thread by default, this is now optional. It is also possible to share sockets among threads, safely, and thus using fewer total sockets, by creating a Connection or ReplicaSetConnection with auto_start_request=False.
* In the past, when a thread died without calling end_request() its socket was closed. We now reclaim such sockets for the pool, which should reduce connection churn.
* start_request() now returns a context manager so you can do "with connection.start_request():"
* ReplicaSetConnection now supports start_request, although its semantics aren't consistent for ReadPreferences other than PRIMARY
* Refactoring: Connection and ReplicaSetConnection had different pool implementations, now they share one.
Also PYTHON-162 and PYTHON-189.
Credit goes to James Murty for most of the patch.
With this change we cache auth credentials (user,
password) in the driver so that each new socket
can be automatically authenticated. This solves
the problem of each new spawned thread having to
re-authenticate.
Makes driver ~2x faster for simple benchmarks.
DEPRECATED pool_size, auto_start_request and timeout parameters to Connection
DEPRECATED Connection.start_request
Each thread now gets it's own socket reserved on it's first operation. Those
sockets are held until Connection.end_request is called by that thread, or
Connection.disconnect is called by any thread, or the thread dies.
Calling Connection.end_request allows the socket to be returned to the pool,
and to be used by other threads instead of creating a new socket. Judicious use
of this method is important for applications with many threads or with long
running threads that make few calls to PyMongo operations.
Exception in thread Thread-58 (most likely raised during interpreter shutdown): Exception in thread Thread-62 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
File "/usr/lib/python2.5/threading.py", line 486, in __bootstrap_inner
File "/home/art/git/mongo-python-driver/test/test_threads.py", line 31, in run
File "/home/art/git/mongo-python-driver/pymongo/cursor.py", line 411, in next
<type 'exceptions.TypeError'>: 'NoneType' object is not callable
Signed-off-by: Mike Dirolf <mike@dirolf.com>