-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-4669 - Update Async GridFS APIs for Motor Compatibility #1821
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
Merged
Changes from 5 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
00f569b
PYTHON-4669 - Update More APIs for Motor Compatibility
NoahStapp 54d333a
Motor compat changes
NoahStapp 397ea6b
Cleanup
NoahStapp c36d5d5
AsyncGridOut fixes
NoahStapp 33867e5
Merge branch 'master' into PYTHON-4669
NoahStapp 66e104c
WIP
NoahStapp c313064
Add async test_grid_file
NoahStapp 911c487
Fix pre-3.9 async imports
NoahStapp f9930b1
Whoops
NoahStapp a9cf616
Fix helpers
NoahStapp d1e0ed0
Fixes
NoahStapp 4847621
Address review
NoahStapp f0293d5
Address review
NoahStapp 4498f65
Fixes
NoahStapp 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1400,7 +1400,10 @@ async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> Any: | |
return False | ||
|
||
|
||
class AsyncGridOut(io.IOBase): | ||
GRIDOUT_BASE_CLASS = io.IOBase if _IS_SYNC else object | ||
|
||
|
||
class AsyncGridOut(GRIDOUT_BASE_CLASS): | ||
"""Class to read data out of GridFS.""" | ||
|
||
def __init__( | ||
|
@@ -1486,13 +1489,14 @@ def __init__( | |
_file: Any | ||
_chunk_iter: Any | ||
|
||
async def __anext__(self) -> bytes: | ||
return super().__next__() | ||
if not _IS_SYNC: | ||
|
||
def __next__(self) -> bytes: # noqa: F811, RUF100 | ||
if _IS_SYNC: | ||
return super().__next__() | ||
else: | ||
async def __anext__(self) -> bytes: | ||
return await self.readline() | ||
|
||
# This is a duplicate definition of __next__ for the synchronous API | ||
# due to the limitations of our synchro process | ||
def __next__(self) -> bytes: # noqa: F811, RUF100 | ||
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. Let's just remove |
||
raise TypeError( | ||
"AsyncGridOut does not support synchronous iteration. Use `async for` instead" | ||
) | ||
|
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.
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.
We need to handle the end-of-stream and raise StopAsyncIteration here. Could you add a test for this?