Skip to content
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-1014 Add __aenter__ and __aexit__ for AgnosticBaseCursor so that cursor can be instantiated using the context manager #172

Merged
merged 3 commits into from Aug 17, 2022

Conversation

coderk17
Copy link
Contributor

@coderk17 coderk17 commented Aug 6, 2022

When I use the following code:

async with self.coll.find() as cursor:
    async for record in cursor:
        yield record

It's going to throw an AttributeError
So I added the asynchronous context manager method
so that I did not have to close the cursor when I was done with it

… cursor can be instantiated using the context manager
@ShaneHarvey ShaneHarvey changed the title MOTOR-981 Add __aenter__ and __aexit__ for AgnosticBaseCursor so that cursor can be instantiated using the context manager MOTOR-1014 Add __aenter__ and __aexit__ for AgnosticBaseCursor so that cursor can be instantiated using the context manager Aug 8, 2022
@ShaneHarvey
Copy link
Member

This seems reasonable to me although I'd like to figure why it wasn't added to begin with. @coderk17 could you add some tests for find() and aggregate() to test/asyncio_tests/test_asyncio_cursor.py?

Opened MOTOR-1014 to track.

@coderk17
Copy link
Contributor Author

coderk17 commented Aug 9, 2022

Sure, the project is great and I'm using it, and I'm glad to add these unit tests. @ShaneHarvey

@coderk17
Copy link
Contributor Author

This seems reasonable to me although I'd like to figure why it wasn't added to begin with. @coderk17 could you add some tests for find() and aggregate() to test/asyncio_tests/test_asyncio_cursor.py?

Opened MOTOR-1014 to track.

Hello, unit tests have been added and passed. @ShaneHarvey

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.

Lgtm

@ShaneHarvey ShaneHarvey merged commit 4c704fb into mongodb:master Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants