-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-5044 - Fix successive AsyncMongoClients on a single loop always ti… #2065
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
Changes from 1 commit
5a1e7cb
cdc2cf0
b898826
6547c3c
f1f8d62
a4eedb3
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 |
---|---|---|
|
@@ -75,6 +75,8 @@ def close(self, dummy: Any = None) -> None: | |
callback; see monitor.py. | ||
""" | ||
self._stopped = True | ||
if self._task: | ||
self._task.cancel() | ||
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'm wondering how this relates to the issue described in DRIVERS-3076. Like will calling cancel here change the user visible events a Monitor emits on 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. Ping. 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. When a task is cancelled, it should stop executing on the next iteration of the event loop. Since 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 see, if we use this approach then we won't emit the expected ServerHeartbeatFailedEvent on cancellation. Do we need this change in this PR anymore? Can we defer it? 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. Good catch. Now that we aren't awaiting background tasks on close in this PR, this change is unneeded. |
||
|
||
async def join(self, timeout: Optional[int] = None) -> None: | ||
if self._task is not None: | ||
|
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.
Yielding here doesn't guarantee anything about task cleanup. Shouldn't we actually await the tasks to ensure they are cleaned up properly?