Commit Graph

77 Commits

Author SHA1 Message Date
Noah Stapp
34ca694c9f
PYTHON-3801 gRPC POC phase 1 (#1317) 2023-07-26 14:01:22 -07:00
Iris
dbb196fdfc
PYTHON-3810 add types to network.py (#1303) 2023-07-13 11:29:33 -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
Shane Harvey
935f926bd9
PYTHON-3362 Ignore wtimeout when timeoutMS or timeout() is configured (#1013)
Apply client timeoutMS to gridfs operations.
2022-07-19 17:46:09 -07:00
Shane Harvey
890cd26e1a
PYTHON-3288 Implement client side operation timeout (#954)
Add timeoutMS URI option and MongoClient keyword argument.
Add provisional/beta pymongo.timeout() api to set a deadline for a block of operations.
2022-06-06 15:36:52 -04:00
Shane Harvey
c58950a8d4
PYTHON-3186 Avoid SDAM heartbeat timeouts on AWS Lambda (#912)
Poll monitor socket with timeout=0 one last time after timeout expires.
This avoids heartbeat timeouts and connection churn on Lambda and other FaaS envs.
2022-03-30 14:29:46 -07:00
Steven Silvester
a0fe7c03af
PYTHON-3120 Set up flake8 linting (#868) 2022-02-17 06:44:08 -06:00
Steven Silvester
5578999a90
PYTHON-1834 Use a code formatter (#852) 2022-02-09 06:44:28 -06:00
Steven Silvester
dd6c140d43
PYTHON-3060 Add typings to pymongo package (#831) 2022-02-02 21:12:36 -06:00
Shane Harvey
ff3a8b44dc
PYTHON-1864 PYTHON-2931 Spec complaint $readPreference (#809)
Stop sending $readPreference to standalone servers.
Stop sending $readPreference primary because it's the server default.
Remove outdated secondary_ok flag.
2021-12-13 15:47:34 -08:00
Shane Harvey
797197e73b
PYTHON-2763 Remove outdated check_keys and $clusterTime logic (#817) 2021-12-10 10:22:49 -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
Bernie Hackett
146179db53 PYTHON-2803 Eliminate the use of 'slave' 2021-09-13 12:47:24 -07:00
Shane Harvey
369d175993
PYTHON-2430 Remove all helpers in the message module (#695) 2021-08-06 13:33:21 -07:00
Shane Harvey
01e34cebdb
PYTHON-2769 Test redaction of replies to security-sensitive commands (#676)
Resync command monitoring and unified test format tests.
Redact entire hello response when the command started contained speculativeAuthenticate.
Make OP_REPLY cursor.cursor_id always be an Int64.
2021-07-15 14:12:11 -07:00
Shane Harvey
4152600ae6
PYTHON-2777 Raise client side error for snapshot reads on <5.0 (#659) 2021-06-29 14:40:48 -07:00
Shane Harvey
14160aed04
PYTHON-2767 Support snapshot reads on secondaries (#656)
Add the MongoClient.start_session snapshot option.
2021-06-25 16:12:12 -07:00
Prashant Mital
ff6ca53328
PYTHON-2572 Introduce NotPrimaryError and deprecate NotMasterError (#646) 2021-06-22 13:24:07 -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
4364b7c43a
PYTHON-2596 Include host in error message when connection is closed (#575)
Use raise from syntax when re-raising exceptions in the pool.
2021-03-03 16:33:42 -08:00
Bernie Hackett
cf877e95c7 PYTHON-2503 Always use time.monotonic
For monotonic time needs.
2021-01-25 12:48:31 -08:00
Bernie Hackett
6c2d629006 PYTHON-2133 Remove Py2 compatibility from pymongo 2021-01-19 21:15:20 -08:00
Shane Harvey
b2fba416e9
PYTHON-2342 Prefer checking error codes over error messages (#492) 2020-10-02 11:30:39 -07:00
Prashant Mital
d97a43ea9b
cleanup 2020-07-01 16:58:56 -07:00
Prashant Mital
956ce3d4b0
Incorporate review changes 2020-07-01 16:47:33 -07:00
Shane Harvey
1f4123e4bf PYTHON-2123 Streaming heartbeat protocol
MongoClient now requires 2 connections and 2 threads to each MongoDB 4.4+ server.
With one connection, the server streams (or pushes) updated heartbeat info.
With the other connection, the client periodically pings the server to
establish an accurate round-trip time (RTT). This change optimizes the
discovery of server state changes such as replica set elections.

Additional changes:
- Mark server Unknown before retrying isMaster check.
- Always reset the pool _after_ marking the server unknown.
- Configure fail point before creating the client in test SpecRunner.
- Unfreeze with replSetFreeze:0 to ensure a speedy elections in test suite.
2020-07-01 14:49:46 -07:00
Bernie Hackett
5df94d08f0 PYTHON-2040 PyOpenSSL support 2020-02-06 18:03:21 -08:00
Prashant Mital
f62c53f472
PYTHON-2020 Make ClientSession._in_transaction a public property 2019-11-01 16:58:38 -07:00
Shane Harvey
58866319f9 PYTHON-1884 Support auto encryption in cursors 2019-08-06 14:54:23 -07:00
Shane Harvey
8888e977f8 PYTHON-1884 Support auto encryption in network.command
Add encryption I/O callbacks.
Add mongocryptd process management.
Add simple test for auto encryption round trip.
2019-08-06 14:54:23 -07:00
Shane Harvey
2cb34e4efc PYTHON-1814 Support custom type decoder with distinct
Fix pure python custom type decoding of bson arrays.
2019-04-17 15:44:51 -07:00
Prashant Mital
749116287a
PYTHON-1783 Decode user-facing documents but not internal driver-server
communications.
2019-04-16 15:01:42 -07:00
Shane Harvey
e64945101b PYTHON-1684 Support sharded transactions recovery token (#406)
Transient errors inside transaction unpins the session.
Add brief docs about sharded transactions and add 3.9 changelog.
Tests changes:
Add spec tests for sharded transaction recoveryToken.
Speed up txn tests by reducing SDAM waiting time after a network error.
Remove outdated test workaround for killAllSessions.
2019-02-27 15:59:18 -08:00
Shane Harvey
3b9e99015f PYTHON-1508 Only send readConcern on first command in a transaction 2018-06-24 11:39:23 -04:00
Shane Harvey
05c7c65470 PYTHON-1329 OP_MSG with unacknowledged writes
Replace OP_INSERT/OP_UPDATE/OP_DELETE usage with OP_MSG with moreToCome
flag when the server is 3.6 or greater.
Unack'ed OP_MSG supports bypass_document_validation.
getLastError updatedExisting is always false on mongos after an OP_MSG
unack'ed update.
2018-06-23 11:46:50 -04:00
Shane Harvey
ea8cb6c209 PYTHON-1329 Send/receive commands as OP_MSG
Don't use $query with OP_MSG.
Support compression with OP_MSG.
2018-06-21 15:46:48 -07:00
Bernie Hackett
335cb97a34 PYTHON-1278, PYTHON-1553 - Support OP_COMPRESSED 2018-05-22 11:44:21 -07:00
Shane Harvey
04693ae33a PYTHON-1513 Efficiently read data using memoryview and recv_into
On Python 2, preallocate a bytearray and use slice assignment instead of
using str +=.
On Python 3, preallocate a bytearray and use a memoryview with recv_into.
2018-05-08 11:28:12 -07:00
Shane Harvey
09891a4ff3 Bring autoStartTransaction up to spec 2018-04-16 09:57:45 -04:00
A. Jesse Jiryu Davis
9df87b6401 prototype transaction tests 2018-04-16 09:57:45 -04:00
Bernie Hackett
507f954ed4 Update copyright dates 2017-12-01 17:23:39 -08:00
Shane Harvey
2a05236f61 PYTHON-1332 Only gossip cluster time on >= 3.6.
Do not add readConcern to explain.
Test explain with collation.
2017-11-30 14:53:14 -08:00
Shane Harvey
b669cd86dc PYTHON-1332 Session may only be used by the client that started it.
Centralize $clusterTime receiving.
2017-11-17 09:27:21 -08:00
Bernie Hackett
99aefd6847 PYTHON-1413 - Restrict when we add readConcern 2017-11-16 19:12:23 -08:00
Bernie Hackett
4eda4ffaec PYTHON-1340 - Implement causally consistent reads 2017-11-09 17:16:55 -08:00
Shane Harvey
8b1aa3aafa PYTHON-1339 Retryable single-statement writes.
Add retryWrites MongoClient and URI setting.
Retry once for supported single-statement write operations including:
insert_one, update_one, delete_one, find_one_and_update, find_one_and_replace,
find_one_and_delete, update and remove with multi=False, and find_and_modify.
2017-10-30 14:23:16 -04:00
Bernie Hackett
822ae0f6c6 PYTHON-1391 - Only use bare except: when re-raising 2017-10-27 13:45:25 -07:00
A. Jesse Jiryu Davis
df018e88e2 PYTHON-1332 - Gossip $clusterTime 2017-10-12 09:08:38 -04:00
Shane Harvey
f0b847adb8 PYTHON-1329 Refactor wire protocol message parsing.
Use _OpReply class instead of passing bytes around.
Remove unnecessary operation argument to receive message.
Move _first_batch to message.py to avoid circular import.
2017-10-09 15:11:50 -07:00
A. Jesse Jiryu Davis
dad61a058b PYTHON-1332 - Update session's last_use 2017-10-05 15:03:36 -04:00