-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-4725 Async client should use tasks for SDAM instead of threads #1896
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
Merged
sleepyStick
merged 26 commits into
mongodb:async-improvements
from
sleepyStick:PYTHON-4725
Oct 12, 2024
Merged
Changes from 2 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
19f14a9
create AsyncPeriodicExecutor
sleepyStick 59c0733
fix tests
sleepyStick 3f5dda7
undo lock changes
sleepyStick 65301cf
found some more lock changes to undo and remove atexit for async
sleepyStick 8852bc9
hacky fix to PeriodicExecutor being defined twice and fix unwanted co…
sleepyStick 5c9b1d9
add missing awaits
sleepyStick ce322f5
attempt to fix test
sleepyStick 549645b
left out an await
sleepyStick c92f6af
add missing await and fix typing errors
sleepyStick c58448f
realizing condition needs to be reverted too
sleepyStick 43660d9
reset client context after primary steps down
sleepyStick dbb51e2
ignore type error on sync
sleepyStick 3c640e8
temp changing pytests's setup and teardown are run to see if this wil…
sleepyStick 0fc60ba
only reset client context after primary_stepdown
sleepyStick f78ee91
only recreate client context in async version
sleepyStick cebbd6f
move periodic_executor.py up a lvl
sleepyStick adf0504
mutate client context to reset it
sleepyStick 56b37c2
remove type ignore
sleepyStick 938c8a7
make PeriodicExecutor sync only
sleepyStick 99c3815
fix reset_client_context
sleepyStick 7ece812
change pytest fixture scope
sleepyStick 3924d80
update AsyncPeriodicExecutors docs
sleepyStick 9631ed6
fix scope typo
sleepyStick 0aa9075
fix task/thread name and delete commented out code
sleepyStick 6597803
fix string typo in synchro and comment string
sleepyStick 541b72d
Merge remote-tracking branch 'upstream/async-improvements' into PYTHO…
sleepyStick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This won't work because there is already an event loop running, we need something like https://github.com/minrk/asyncio-atexit
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.
yeah, something was funky HAHA thanks for showing me a fix!
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.
Background: https://discuss.python.org/t/atexit-for-asyncio/13911/10
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.
would i be allowed to import this and use the package? or should i just take the code that we need and put in on our own code base? thoughts?
Uh oh!
There was an error while loading. Please reload this page.
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.
Do we need this at all? What happens if we do nothing for async clients at exit?
Do our SDAM tasks prevent the loop from exiting?
We document that an AsyncMongoClient must always be closed() so I don't believe we need to do anything. If the app leaves the client open, that's a bug.
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.
I took it out of async and it seems to be fine so far.