Allow cursor to be used in async with-statement

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Unknown
    • 3.1
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Allow find/aggregate cursors to be used in async with-statements. Reported here: https://github.com/mongodb/motor/pull/172

      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

              Assignee:
              Julius Park (Inactive)
              Reporter:
              Shane Harvey
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: