Commit Graph

54 Commits

Author SHA1 Message Date
Noah Stapp
d0193eb045
PYTHON-4533 - Convert test/test_client.py to async (#1730) 2024-07-10 13:15:13 -07:00
Noah Stapp
ffa6555485
PYTHON-4476 Separate data and IO classes more effectively (#1678) 2024-06-26 10:12:39 -07:00
Noah Stapp
d6bf0e1e78
PYTHON-4264 Async PyMongo Beta (#1629) 2024-06-06 09:01:24 -07:00
Steven Silvester
923c8a5abe
PYTHON-4024 Use ruff formatter (#1419) 2023-11-02 12:46:40 -05:00
Steven Silvester
992d1507e7
PYTHON-4005 Replace flake8 and isort with ruff (#1399) 2023-10-19 11:56:22 -05:00
Iris
883d57f7ce
PYTHON-3808 add types to monitor.py (#1328) 2023-08-01 09:41:07 -07:00
Noah Stapp
c88ae79e58
PYTHON-3879 Rename SocketInfo to Connection (#1329) 2023-07-28 10:04:16 -07:00
Shane Harvey
0092b0af79
PYTHON-2504 Run pyupgrade 3.4.0 and ruff 0.0.265 (#1196)
pyupgrade --py37-plus bson/*.py pymongo/*.py gridfs/*.py test/*.py tools/*.py test/*/*.py
ruff --fix-only --select ALL --fixable ALL --target-version py37 --line-length=100 --unfixable COM812,D400,D415,ERA001,RUF100,SIM108,D211,D212,SIM105,SIM,PT,ANN204,EM bson/*.py pymongo/*.py gridfs/*.py test/*.py test/*/*.py
2023-05-11 15:27:17 -07:00
Steven Silvester
5578999a90
PYTHON-1834 Use a code formatter (#852) 2022-02-09 06:44:28 -06:00
Shane Harvey
c94a3ad1df
PYTHON-2585 Remove legacy multi-auth code (#816) 2021-12-09 18:00:41 -08:00
Bernie Hackett
ad4315134c PYTHON-2803 Get rid of most uses of 'master'
This change also resolves PYTHON-2848 for MongoDB 4.0.
2021-09-13 12:50:49 -07:00
Prashant Mital
3f8c104157
PYTHON-2288 Remove IsMaster (#690) 2021-07-29 10:32:51 -07:00
Shane Harvey
4c77d7c855
PYTHON-2677 Better wait queue timeout errors for load balanced clusters (#639)
Remove checkout argument in favor of SocketInfo.pin_txn/pin_cursor()
2021-06-21 18:29:36 -07:00
Shane Harvey
c8f32a7a37 PYTHON-2673 Connection pinning behavior for load balanced clusters (#630)
Tweak spec test because pymongo unpins cursors eagerly after errors.
Tweak spec test for PoolClearedEvent ordering when MongoDB handshake fails (see DRIVERS-1785).
Only skip killCursors for some error codes.
Rely on SDAM error handling to close the connection after a state change error.
Add service_id to various events.
Retain reference to pinned sockets to prevent premptive closure by CPython's cyclic GC.
2021-06-15 14:14:56 -07:00
Shane Harvey
4c7718eb5a
PYTHON-2634 Only update pools for data-bearing servers (#590)
Fixes a noisy OperationFailure: Authentication failed error.
Do not attempt to create unneeded connections to arbiters, ghosts,
hidden members, or unknown members.
2021-04-19 13:24:54 -07:00
Shane Harvey
86b40c195d
PYTHON-2462 Avoid connection storms: implement pool PAUSED state (#531)
Mark server unknown and clear the pool when background connections fail.
Eagerly evict threads from the wait queue when pool is paused. Evicted
threads will raise the following error:
AutoReconnect('localhost:27017: connection pool paused')
Introduce PoolClearedEvent and ConnectionPoolListener.pool_ready.

CMAP spec test changes:
- CMAP unit tests should not use real monitors
- Assert that CMAP threads complete all scheduled operations
2021-01-06 15:15:37 -08:00
Shane Harvey
5b49557c59 PYTHON-2268 Close clients in test suite 2020-06-03 17:05:59 -07:00
Shane Harvey
2c631faa6c PYTHON-2239 Avoid 30 second stalls in TestMongoClientFailover 2020-05-13 16:53:34 -07:00
Bernie Hackett
cb85eb02a2 PYTHON-1563 - Avoid import deadlocks in the test suite 2018-06-03 07:34:26 -07:00
Bernie Hackett
335cb97a34 PYTHON-1278, PYTHON-1553 - Support OP_COMPRESSED 2018-05-22 11:44:21 -07:00
Bernie Hackett
507f954ed4 Update copyright dates 2017-12-01 17:23:39 -08:00
A. Jesse Jiryu Davis
dcd8f68994 PYTHON-1332 - send $clusterTime with isMaster 2017-10-23 18:01:59 -04:00
A. Jesse Jiryu Davis
b273d94358 PYTHON-1299 - Use new wire version in tests 2017-08-24 08:57:36 -04:00
A. Jesse Jiryu Davis
726921a034 Revert "PYTHON-1163 update topology from handshake reply"
23d3c2ee86
2016-11-23 11:43:23 -05:00
A. Jesse Jiryu Davis
23d3c2ee86 PYTHON-1163 update topology from handshake reply 2016-11-22 16:36:32 -05:00
Shane Harvey
5905a86785 PYTHON-1075 Support running the entire test suite with SSL/TLS
SSL connections are configurable via the environment variables
"CLIENT_PEM", "CA_PEM", and "CERT_REQS".
2016-09-28 16:34:14 -07:00
Bernie Hackett
e89ba4bcd0 PYTHON-1026 - Remove test assumption about primary host 2016-09-21 11:15:43 -07:00
Luke Lovett
c9bbfa7ace PYTHON-1119 - Implement the client metadata capture specification. 2016-07-26 10:35:55 -07:00
aherlihy
10608144d6 PYTHON-658 - Support minPoolSize, maxIdleTimeMS 2016-06-14 14:37:06 +02:00
Bernie Hackett
aec685b374 Fix up copyright dates. 2015-03-25 11:55:02 -07:00
A. Jesse Jiryu Davis
f737ec0db9 PYTHON-728 - Translate socket.error to ConnectionFailure in pool.py.
SocketInfo and Pool are now responsible for catching all socket.errors and
gaierrors and translating them to ConnectionFailure. Server and MongoClient
need no longer worry about anything but ConnectionFailure. Functions in pool.py
and network.py still throw socket.errors into SocketInfo and Pool.
2015-03-11 19:57:01 -04:00
A. Jesse Jiryu Davis
ea8ca5ec7d PYTHON-852 - Mongos load balancing.
The behavior for a list of mongoses is changed from "high availability" to
"load balancing". Before, the client connected to the lowest-latency mongos in
the list, and used it until a network error prompted it to re-evaluate all
mongoses' latencies and reconnect to one of them. In PyMongo 3, the client
monitors its network latency to all the mongoses continuously, and distributes
operations evenly among those with the lowest latency. See
high_availability.rst.
2015-03-08 08:25:13 -04:00
A. Jesse Jiryu Davis
9b208caed9 PYTHON-829 Call ismaster on each new connection.
Call ismaster on each new connection and store the results on the SocketInfo
instance.

The upcoming Authentication Spec says: "If credentials exist, upon opening a
socket, drivers MUST send an isMaster command immediately. This allows a driver
to determine whether the server is an Arbiter. Calling ismaster additionally
allows the driver to know if the default authentication method for each socket
is MONGODB-CR or SCRAM-SHA-1, avoiding races when the driver repopulates the
pool after a disconnect."

In theory we could choose not to call ismaster if there are no credentials, but
it's simpler always to call ismaster, and paves the way for future breaking
changes to the wire protocol besides the current breaking change to
authentication.
2015-01-26 16:54:14 -05:00
A. Jesse Jiryu Davis
47a736da89 PYTHON-799 Avoid deadlock in Cursor destructor with PyPy.
Use a background thread to periodically close destroyed
cursors instead of killing them directly from Cursor.__del__.
2015-01-05 15:21:51 -05:00
A. Jesse Jiryu Davis
515d6bf7e4 Style in pymongo_mocks.py. 2014-12-03 18:11:58 -05:00
A. Jesse Jiryu Davis
197fb30312 Avoid ResourceWarning with MockPool tests in Python 3.3. 2014-12-03 18:10:50 -05:00
A. Jesse Jiryu Davis
0b9b109e3c Make Pool.get_socket a context manager.
SocketInfo itself is no longer a context manager.
Simplifies exhaust cursors and exception handling,
and avoids a confusing weakref.
2014-12-03 16:32:41 -05:00
A. Jesse Jiryu Davis
ecc55f502a New method to calculate average round trip time.
Replace 5-sample moving average with exponentially weighted average,
required by the upcoming Server Selection Spec. Move responsibility for
tracking the average from ServerDescription to Monitor. Now the
ServerDescription only knows the average at the time it was created.
2014-12-03 16:30:35 -05:00
A. Jesse Jiryu Davis
ff7958ad38 PYTHON-525 Helpful connection error messages. 2014-11-18 12:14:35 -05:00
A. Jesse Jiryu Davis
ee11436675 PYTHON-764 SCRAM-SHA-1 automatic upgrade / downgrade. 2014-10-23 16:30:55 -04:00
A. Jesse Jiryu Davis
647ed74dcf PYTHON-525 Remove "force" param for Pool.get_socket().
MongoReplicaSetClient's old monitor used "force" to get a socket even when the
pool had reached its max size. This was so complicated and bug-prone that I
prohibited it in the Server Discovery And Monitoring Spec: monitors use
dedicated sockets now instead of sharing a pool with the application.
2014-09-25 11:32:06 -04:00
A. Jesse Jiryu Davis
98afef5871 Replace "Cluster" term with "Topology".
The Server Discovery And Monitoring Spec has replaced the term "cluster"
with "topology", since "cluster" in MongoDB terminology should be reserved
for sharded clusters. "Topology" describes a single server, replica set, or a
set of mongoses.

The previous commit replaced "cluster" with "topology" in file names. Here
I replace the term in class and variable names.
2014-09-17 22:32:43 -04:00
A. Jesse Jiryu Davis
735a1247ca PYTHON-525 Deprecate MongoReplicaSetClient.
MongoClient now supports all MongoReplicaSetClient's features.
Fix bugs and add features in the new MongoClient to bring it up
to spec. MongoReplicaSetClient is now a deprecated stub that
subclasses MongoClient.

Introduce new errors, NetworkTimeout and NotMasterError, to
communicate events that MongoClient must handle specially.
2014-09-16 15:33:19 -04:00
A. Jesse Jiryu Davis
41c1a9afa6 PYTHON-525 Reimplement auth for new MongoClient.
The new MongoClient, based on Cluster and Server,
includes functionality that had been split between the
old MongoClient and MongoReplicaSetClient. A
previous commit introduced the new MongoClient
but broke authentication.
2014-09-03 17:39:52 -04:00
A. Jesse Jiryu Davis
2f9d24ade6 PYTHON-525 Reimplement MongoClient to use Cluster.
Replace MongoClient with an implementation that relies on Cluster and Server. The new MongoClient takes over MongoReplicaSetClient's responsibilities.

Authentication, secondary-pinning, and Mongos high-availability are broken and will be reimplemented in a future commit. RS tests are temporarily disabled.
2014-08-28 16:57:57 -04:00
Bernie Hackett
c2e6471ee6 PYTHON-727 - Implement and use PoolOptions class 2014-07-03 14:10:37 -07:00
Bernie Hackett
80a789e167 PYTHON-718 - Use SSLContext when available.
This commit also introduces a fake SSLContext class
for use in python versions that don't provide one.
2014-06-25 16:09:55 -07:00
A. Jesse Jiryu Davis
6d5f658c2a Use maxWriteBatchSize for write command batch splitting, PYTHON-642. 2014-02-21 14:05:40 -05:00
A. Jesse Jiryu Davis
2fa1750b07 Update copyright notices and company name. 2014-01-31 09:36:46 -05:00
A. Jesse Jiryu Davis
3757086e02 Raise ConfigurationError if a server's min wire version is > 2, PYTHON-587. 2013-12-14 12:57:09 -05:00