Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-5035

Tailable Cursors should raise exception on to_list for PyMongo

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 4.12
    • Component/s: None
    • None
    • None
    • Python Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      Context

      The `to_list` abstraction is meant to return the entire list. Tailable cursors are meant to exist in perpetuity, even after there are no more elements produced in the cursor. As such, this yields unexpected behavior as the cursor could hang indefinitely or raise Exceptions.

      Detailed steps to reproduce the problem?

      pip install PyMongo

      create a capped collection

      create a tailable cursor from capped collection

      call to_list

      ```python

      import time

      import pymongo

      client = pymongo.MongoClient()
      oplog = client.local.oplog.rs
      first = oplog.find().sort('$natural', pymongo.ASCENDING).limit(-1).next()
      print(first)
      ts = first['ts']

      cursor = oplog.find({'ts': {'$gt': ts}},
                              cursor_type=pymongo.CursorType.TAILABLE_AWAIT,
                              oplog_replay=True)
      cursor.to_list(length=None)

      ```

      Definition of done: what must be done to consider the task complete?

      The exact Python version used, with patch level:

      $ python -c "import sys; print(sys.version)"

      The exact version of PyMongo used, with patch level:

      $ python -c "import pymongo; print(pymongo.version); print(pymongo.has_c())"

      Describe how MongoDB is set up. Local vs Hosted, version, topology, load balanced, etc.

      The operating system and version (e.g. Windows 7, OSX 10.8, ...)

      Web framework or asynchronous network library used, if any, with version (e.g. Django 1.7, mod_wsgi 4.3.0, gevent 1.0.1, Tornado 4.0.2, ...)

      Security Vulnerabilities

      If you’ve identified a security vulnerability in a driver or any other MongoDB project, please report it according to the instructions here

            Assignee:
            Unassigned Unassigned
            Reporter:
            jib.adegunloye@mongodb.com Jib Adegunloye
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: