-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-5169 - Deprecate Hedged Reads option #2213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
d5aa363
396b076
ce05c69
5b87911
c492a8f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
|
||
from __future__ import annotations | ||
|
||
import warnings | ||
from collections import abc | ||
from typing import TYPE_CHECKING, Any, Mapping, Optional, Sequence | ||
|
||
|
@@ -103,6 +104,11 @@ def _validate_hedge(hedge: Optional[_Hedge]) -> Optional[_Hedge]: | |
if not isinstance(hedge, dict): | ||
raise TypeError(f"hedge must be a dictionary, not {hedge!r}") | ||
|
||
warnings.warn( | ||
"Hedged reads are deprecated starting in server version 8.0.", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
|
||
) | ||
return hedge | ||
|
||
|
||
|
@@ -143,6 +149,11 @@ def document(self) -> dict[str, Any]: | |
if self.__max_staleness != -1: | ||
doc["maxStalenessSeconds"] = self.__max_staleness | ||
if self.__hedge not in (None, {}): | ||
warnings.warn( | ||
|
||
"Hedged reads are deprecated starting in server version 8.0.", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
|
||
doc["hedge"] = self.__hedge | ||
return doc | ||
|
||
|
@@ -203,6 +214,12 @@ def hedge(self) -> Optional[_Hedge]: | |
|
||
.. versionadded:: 3.11 | ||
""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's update this docstring with |
||
if self.__hedge is not None: | ||
warnings.warn( | ||
"Hedged reads are deprecated starting in server version 8.0.", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
return self.__hedge | ||
|
||
@property | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,6 +119,7 @@ filterwarnings = [ | |
"module:please use dns.resolver.Resolver.resolve:DeprecationWarning", | ||
# https://github.com/dateutil/dateutil/issues/1314 | ||
"module:datetime.datetime.utc:DeprecationWarning", | ||
"module:Hedged reads are deprecated:DeprecationWarning", | ||
|
||
] | ||
markers = [ | ||
"auth_aws: tests that rely on pymongo-auth-aws", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mentioning the server side deprecation is good but we should first mention the driver side deprecation. Something like:
the read preference "hedge" option is deprecated in PyMongo 4.12+ because hedged reads are deprecated in MongoDB version 8.0+. Support for "hedge" will be removed in PyMongo 5.0.