Commit Graph

110 Commits

Author SHA1 Message Date
Jeffrey A. Clark
166821f22c
PYTHON-5205 Replace http with https in doc links (#2204) 2025-03-14 21:37:11 -04:00
Steven Silvester
57305e0179
PYTHON-4747 Sync client_session.py to master 2024-09-10 12:16:01 -05:00
Steven Silvester
4436b1c676
PYTHON-4747 Rename pymongo/client_session.py to pymongo/synchronous/client_session.py 2024-09-10 12:16:01 -05:00
Noah Stapp
ebb94b669e
PYTHON-3457 Easier debugging with standardized logging (#1515)
PYTHON-3458 Add command logging.
PYTHON-3459 Add server selection logging.
PYTHON-3473 Add connection pool logging.
PYTHON-4167 Add documentation and examples.

Co-authored-by: sleepyStick <itsirisho@gmail.com>
2024-02-15 11:35:08 -08:00
Noah Stapp
62c6d0f330
PYTHON-3587 Do not perform server selection to determine sessions support (#1491) 2024-02-05 13:19:26 -08:00
Jib
60d0761527
PYTHON-2884: Replaced SON usage in all internal classes and commands (#1426) 2023-12-19 15:42:23 -08:00
Steven Silvester
6537415da7
PYTHON-3605 Move type annotations to parameter list in rendered docs (#1441) 2023-11-27 09:24:00 -06:00
Steven Silvester
992d1507e7
PYTHON-4005 Replace flake8 and isort with ruff (#1399) 2023-10-19 11:56:22 -05:00
Steven Silvester
6f4e617e6d
PYTHON-3905 Use from __future__ import annotations in all files (#1370)
* PYTHON-3905 Use from __future__ import annotations in all files

* cleanup

* cleanup

* cleanup
2023-09-11 10:49:24 -05:00
Jib
3e1a4ab56e
PYTHON-3739 Refactor retryable reads and writes logic to avoid duplication (#1344)
* first draft commit; consolidated _retryable_(read|write) to call _retry_internal

* removed extra self usage

* formatting

* swapped last_error usage

* switched to using more objective syntax

* black formatter

* don't use conn_from_server

* changed variable naming is_write -> is_read; consolidated errorhandling; revisited is_retrying

* added an explicit if not self._is_read catch

* switched self._in_transaction to be self._not_in_transaction

* fixed logic on checking if a read/write was in transaction and added commentary

* fixed encryption-based error getting retried

* separated server selection as the exception raised gets handled differently in each caller

* do not mutate 'retryable' within the class instantiation

* centralized usage of _retryable_write to avoid _retry_with_session used outwardly

* added docstrings to our _retryable_(read|write) operations

* refactored docstrings to align with rest of the file

* clearer docstrings and function calls
2023-08-29 10:13:38 -04:00
Iris
34da931b3a
PYTHON-3867 add types to topology.py (#1346) 2023-08-09 14:21:43 -07:00
Iris
02a365276c
PYTHON-3806 add types to message.py (#1312) 2023-08-02 20:11:25 -07:00
Iris
b7796e1794
PYTHON-3807 add types to mongo_client.py (#1315) 2023-08-01 16:49:33 -07:00
Noah Stapp
c88ae79e58
PYTHON-3879 Rename SocketInfo to Connection (#1329) 2023-07-28 10:04:16 -07:00
Iris
7bcbb0de9b
PYTHON-3802 add types to database.py (#1295) 2023-07-12 10:48:33 -07:00
Iris
820823891d
PYTHON-3773 add types to client_session.py (#1268) 2023-06-28 11:54:23 -07:00
Noah Stapp
601d1ec3a1
PYTHON-3737 Use __future__ annotations for forward reference type hints (#1234) 2023-06-15 12:54:29 -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
lilinjie
30ebc1d090
fix typo (#1179) 2023-04-04 06:46:14 -05:00
Steven Silvester
e9a6482c4d
PYTHON-3610 Add blacken-docs to pre-commit hook (#1170) 2023-03-14 15:37:45 -05:00
Julius Park
9083821300
PYTHON-3454 Specifying a generic type for a collection does not correctly enforce type safety when inserting data (#1081) 2022-11-01 14:33:21 -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
Steven Silvester
9f191d6bb3
PYTHON-3283 Remove Generic Typing from the ClientSession Class (#952) 2022-05-25 05:55:36 -05:00
Steven Silvester
b3604a81d3
PYTHON-3171 Add usage of NoReturn annotation (#901) 2022-03-16 15:26:10 -05:00
Julius Park
b737b843e9
PYTHON-2956 Drivers should check out an implicit session only after checking out a connection (#876) 2022-03-01 15:44:05 -08: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
e154642968
Removed references to outdated server versions (#812) 2021-12-07 15:47:28 -08:00
Julius Park
4e086ba218
PYTHON-1915 Prohibit copying ClientSession objects (#726) 2021-09-15 12:05:09 -07:00
Shane Harvey
f9bfd11290
PYTHON-2870 Add support for man/text/latex/etc.. docs output (#708)
Regenerate sphinx makefile with sphinx-quickstart 3.5.4.
Remove problematic mongodoc sphinx extension.
2021-08-19 13:31:46 -07:00
Shane Harvey
9bc27c9c0b PYTHON-2797 Update docs for 5.0 support
Add changelog entries for 3.11.2, 3.11.3, and 3.12.0.
2021-08-06 13:29:11 -07:00
Shane Harvey
a142125640
PYTHON-2775 Add docs for snapshot reads (#662) 2021-07-06 11:58:30 -07:00
Shane Harvey
fd845654fb
PYTHON-2776 Disable writes and other unsupported operations in snapshot reads (#660)
Rely on the server to report an error for unsupported snapshot read
operations by sending readConcern with all commands, even writes.
2021-06-30 20:01:43 -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
Shane Harvey
6bc5e088af
PYTHON-1272 Fix deadlock when garbage collecting pinned cursors and sessions (#642)
It's not safe to return the pinned connection to the pool from within
Cursor.del because the Pool's lock may be held by a python thread
while the cyclic garbage collector runs. Instead we send the cursor
cleanup request to the client's background thread. The thread will
send killCursors on the pinned socket and then return the socket to
the pool.
Also fixed a similar bug when garbage collecting a pinned session.
2021-06-22 17:29:26 -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
93ac5e0277
PYTHON-2676 Add load balancer tests in EVG (#625)
Add load balancer spec tests
Ensure LB supports retryable reads/writes
Add assertNumberConnectionsCheckedOut, createFindCursor, ignoreResultAndError
Add PoolClearedEvent.service_id and fix isClientError unified test assertion
2021-05-27 15:05:26 -07:00
Shane Harvey
61c6876872
PYTHON-2635 Unpin sessions after all abortTransaction attempts (#609)
Add unified test runner for transactions.
2021-04-28 12:38:13 -07:00
Shane Harvey
95974617bd
PYTHON-1314 Remove Database.authenticate and Database.logout (#568) 2021-02-17 14:16:07 -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
ac2f506ba2
PYTHON-2453 Add MongoDB Versioned API (#536)
Add pymongo.server_api.ServerApi and the MongoClient server_api option.
Support Unified Test Format version 1.1 (serverParameters in
runOnRequirements)
Skip dropRole tests due to SERVER-53499.
2021-01-11 18:16:00 -08:00
Shane Harvey
17dca5c504 Revert "PYTHON-1915: Prohibit copying ClientSession objects (#480)"
This reverts commit 959039b213.
2020-11-16 15:09:31 -08:00
ishmum123
959039b213
PYTHON-1915: Prohibit copying ClientSession objects (#480) 2020-08-21 11:10:40 -07:00
Shane Harvey
3c1dd61ae9
PYTHON-2256 Document that a ClientSession cannot be used for multiple operations concurrently (#460) 2020-07-08 17:40:02 -07:00
Shane Harvey
45a7963aac PYTHON-2082 Retryable writes use the RetryableWriteError label
Use retryable write logic for transaction commit/abort.
Do not assign the TransientTransactionError label to errors outside a
transaction.
2020-05-19 10:49:28 -07:00
Shane Harvey
350ada10d5 PYTHON-2206 Rename pool_id to generation to better match CMAP spec 2020-04-16 11:46:54 -07:00