Skip to content
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

Merged
merged 10 commits into from
Sep 17, 2024

Conversation

sleepyStick
Copy link
Contributor

No description provided.

@@ -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):
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice.

@blink1073
Copy link
Member

@sleepyStick you'll need to resync from master and use the convenience class methods to create the clients.

@@ -294,6 +295,7 @@ def _clone(self, deepcopy: bool = True, base: Optional[AsyncCursor] = None) -> A
"limit",
"max_time_ms",
"max_await_time_ms",
"timeout",
Copy link
Member

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.

Copy link
Contributor Author

@sleepyStick sleepyStick Sep 17, 2024

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!!

@sleepyStick sleepyStick marked this pull request as ready for review September 17, 2024 20:21
Copy link
Member

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@sleepyStick sleepyStick merged commit c136684 into mongodb:master Sep 17, 2024
34 checks passed
@sleepyStick sleepyStick deleted the PYTHON-4585 branch September 17, 2024 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants