Uploaded image for project: 'Motor'
  1. Motor
  2. MOTOR-938

Docs for watch() incorrectly call ChangeStream.close()

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.0
    • Affects Version/s: None
    • Component/s: Docs
    • None

      The docs for watch() incorrectly call ChangeStream.close():

          try:
              loop.run_forever()
          except KeyboardInterrupt:
              pass
          finally:
              if change_stream is not None:
                  change_stream.close()
      

      https://motor.readthedocs.io/en/stable/api-asyncio/asyncio_motor_collection.html#motor.motor_asyncio.AsyncIOMotorCollection.watch

      change_stream.close() is an async method so calling it without await leaks a coroutine. Really it should work via task cancellation, not through KeyboardInterrupt.

            Assignee:
            steve.silvester@mongodb.com Steve Silvester
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: