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
MOTOR-938 Docs for watch() incorrectly call ChangeStream.close() #163
Changes from 3 commits
eda521e
7190673
b9f84dd
785cd6c
82fd5d0
cb30e51
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 |
---|---|---|
|
@@ -1069,19 +1069,16 @@ def main(): | |
try: | ||
loop.start() | ||
except KeyboardInterrupt: | ||
pass | ||
finally: | ||
if change_stream is not None: | ||
change_stream.close() | ||
loop.add_callback(change_stream.close) | ||
|
||
# asyncio | ||
try: | ||
asyncio.run(watch_collection) | ||
asyncio.run(watch_collection()) | ||
except KeyboardInterrupt: | ||
pass | ||
finally: | ||
if change_stream is not None: | ||
change_stream.close() | ||
asyncio.run(change_stream.close()) | ||
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. Can you confirm that the close() is not needed? I believe the 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. I did some local testing, ensuring that the change_stream was actually closed. |
||
|
||
|
||
The :class:`~MotorChangeStream` async iterable blocks | ||
until the next change document is returned or an error is raised. If | ||
|
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.
Does this actually work? I would expect close to never run since the loop is not running at this point. What if we use loop.run_sync similar to asyncio.run?: