-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-4585 Cursor.to_list does not apply client's timeoutMS setting #1860
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d14a5a4
PYTHON-4585 Cursor.to_list does not apply client's timeoutMS setting
sleepyStick 7aaaa65
require failCommand should fix my errors
sleepyStick d417ae8
attempt to figure out what the failures are...
sleepyStick 458e908
attempt to fix failures
sleepyStick 983bbdb
attempt to fix failures pt2
sleepyStick b420572
remove need for change streams and remove redundant timeout from clone
sleepyStick 0e70ad4
using new way to create clients, still a wip though
sleepyStick 947a332
added blockConnection, tests should pass now
sleepyStick 84a6fe9
use require_failCommand_blockConnection instead of fail_point
sleepyStick 309e60c
okay this should actually pass now
sleepyStick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ | |
AllowListEventListener, | ||
EventListener, | ||
OvertCommandListener, | ||
delay, | ||
ignore_deprecations, | ||
wait_until, | ||
) | ||
|
@@ -44,7 +45,7 @@ | |
from pymongo.asynchronous.cursor import AsyncCursor, CursorType | ||
from pymongo.asynchronous.helpers import anext | ||
from pymongo.collation import Collation | ||
from pymongo.errors import ExecutionTimeout, InvalidOperation, OperationFailure | ||
from pymongo.errors import ExecutionTimeout, InvalidOperation, OperationFailure, PyMongoError | ||
from pymongo.operations import _IndexList | ||
from pymongo.read_concern import ReadConcern | ||
from pymongo.read_preferences import ReadPreference | ||
|
@@ -1410,6 +1411,18 @@ async def test_to_list_length(self): | |
docs = await c.to_list(3) | ||
self.assertEqual(len(docs), 2) | ||
|
||
async def test_to_list_csot_applied(self): | ||
client = await self.async_single_client(timeoutMS=500) | ||
# Initialize the client with a larger timeout to help make test less flakey | ||
with pymongo.timeout(2): | ||
await client.admin.command("ping") | ||
coll = client.pymongo.test | ||
await coll.insert_many([{} for _ in range(5)]) | ||
cursor = coll.find({"$where": delay(1)}) | ||
with self.assertRaises(PyMongoError) as ctx: | ||
await cursor.to_list() | ||
self.assertTrue(ctx.exception.timeout) | ||
|
||
@async_client_context.require_change_streams | ||
async def test_command_cursor_to_list(self): | ||
# Set maxAwaitTimeMS=1 to speed up the test. | ||
|
@@ -1439,6 +1452,25 @@ async def test_command_cursor_to_list_length(self): | |
result = await db.test.aggregate([pipeline]) | ||
self.assertEqual(len(await result.to_list(1)), 1) | ||
|
||
@async_client_context.require_failCommand_blockConnection | ||
async def test_command_cursor_to_list_csot_applied(self): | ||
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. 2 things:
|
||
client = await self.async_single_client(timeoutMS=500) | ||
# Initialize the client with a larger timeout to help make test less flakey | ||
with pymongo.timeout(2): | ||
await client.admin.command("ping") | ||
coll = client.pymongo.test | ||
await coll.insert_many([{} for _ in range(5)]) | ||
fail_command = { | ||
"configureFailPoint": "failCommand", | ||
"mode": {"times": 5}, | ||
"data": {"failCommands": ["getMore"], "blockConnection": True, "blockTimeMS": 1000}, | ||
} | ||
cursor = await coll.aggregate([], batchSize=1) | ||
async with self.fail_point(fail_command): | ||
with self.assertRaises(PyMongoError) as ctx: | ||
await cursor.to_list() | ||
self.assertTrue(ctx.exception.timeout) | ||
|
||
|
||
class TestRawBatchCursor(AsyncIntegrationTest): | ||
async def test_find_raw(self): | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nice.