-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
PYTHON-4585 Cursor.to_list does not apply client's timeoutMS setting #1860
Conversation
@@ -1444,6 +1455,21 @@ 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_change_streams | |||
@async_client_context.require_failCommand_fail_point | |||
async def test_command_cursor_to_list_csot_applied(self): |
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.
2 things:
- Let's use regular aggregate here since there's nothing special about $changeStream here and it complicates the test.
- The failCommands needs to be for "getMore", not "aggregate" since
await client.db.test.aggregate()
actually runs the aggregate command and to_list only runs getMore. We'll need to set batchSize to ensure at least 1 getMore even runs.
cursor = coll.find({"$where": delay(2)}) | ||
with self.assertRaises(PyMongoError) as ctx: | ||
await cursor.to_list() | ||
self.assertTrue(ctx.exception.timeout) |
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.
@sleepyStick you'll need to resync from master and use the convenience class methods to create the clients. |
pymongo/asynchronous/cursor.py
Outdated
@@ -294,6 +295,7 @@ def _clone(self, deepcopy: bool = True, base: Optional[AsyncCursor] = None) -> A | |||
"limit", | |||
"max_time_ms", | |||
"max_await_time_ms", | |||
"timeout", |
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.
We shouldn't need to add timeout here since it's already set implicitly in _clone_base.
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.
hm i didn't at first but i was failing test_clone
and adding this seemed to fix it >.<
i'll undo this change in my next commit though in case i'm mis-remembering
edit: i mis-remembered LOL deleting it passes the test_clone
locally, thanks for pointing this out to me!!
0e54e3d
to
311754d
Compare
bd3c4cd
to
b420572
Compare
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!
No description provided.