Skip to content

Conversation

@Kn99HN
Copy link
Contributor

@Kn99HN Kn99HN commented Apr 20, 2021

Description

  • Add a informative UserWarning when no_cursor_timeout is set

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.

Thanks for taking this one @Kn99HN!

if not isinstance(limit, int):
raise TypeError("limit must be an instance of int")
validate_boolean("no_cursor_timeout", no_cursor_timeout)
if no_cursor_timeout:
Copy link
Member

Choose a reason for hiding this comment

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

suggest: if no_cursor_timeout and not self.__explicit_session:

This way users can avoid seeing the warning by applying the workaround described here: https://docs.mongodb.com/v4.4/reference/method/cursor.noCursorTimeout/#session-idle-timeout-overrides-nocursortimeout

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for pointing this out!

if no_cursor_timeout:
warnings.warn("use an explicit session with no_cursor_timeout=True"\
"otherwise the cursor may still timeout after 30 minutes,"\
"for more info see DOCS-11255",
Copy link
Member

Choose a reason for hiding this comment

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

A few suggestions:

@ShaneHarvey ShaneHarvey merged commit 1818553 into mongodb:master Apr 23, 2021
ShaneHarvey pushed a commit that referenced this pull request Apr 23, 2021
@ShaneHarvey
Copy link
Member

Thanks @Kn99HN!

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.

2 participants