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

Change pymongo so that motor no longer needs to access private cursor apis

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 4.9
    • Affects Version/s: None
    • Component/s: None
    • None
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Currently motor relies on a few private/internal pymongo apis. For example:

      $ git grep -e '[a-zA-Z]__[a-zA-Z]' | tee
      motor/core.py:1500:    _Cursor__die  = AsyncRead()
      motor/core.py:1519:        return self.delegate._Cursor__query_flags
      motor/core.py:1522:        return self.delegate._Cursor__data
      motor/core.py:1525:        return self.delegate._Cursor__killed
      motor/core.py:1537:    _CommandCursor__die = AsyncRead()
      motor/core.py:1543:        return self.delegate._CommandCursor__data
      motor/core.py:1546:        return self.delegate._CommandCursor__killed
      motor/core.py:1557:    _CommandCursor__data = []
      motor/core.py:1558:    _CommandCursor__id = None
      motor/core.py:1559:    _CommandCursor__killed = False
      motor/core.py:1560:    _CommandCursor__sock_mgr = None
      motor/core.py:1561:    _CommandCursor__session = None
      motor/core.py:1562:    _CommandCursor__explicit_session = None
      motor/core.py:1566:        self._CommandCursor__collection = collection.delegate
      motor/core.py:1568:    def _CommandCursor__end_session(self, *args, **kwargs):
      motor/core.py:1571:    def _CommandCursor__die(self, *args, **kwargs):
      motor/core.py:1575:        return _LatentCursor(self._CommandCursor__collection)
      motor/core.py:1635:            if self.delegate._CommandCursor__data or not self.delegate.alive:
      motor/core.py:1638:                    len(self.delegate._CommandCursor__data))
      motor/motor_gridfs.py:43:    _Cursor__die = AsyncCommand()
      synchro/__init__.py:249:    - Certain internals accessed by PyMongo's unittests, such as _Cursor__data,
      synchro/__init__.py:390:    _MongoClient__all_credentials = SynchroProperty()
      synchro/__init__.py:391:    _MongoClient__options         = SynchroProperty()
      synchro/__init__.py:608:    _Cursor__data              = SynchroProperty()
      synchro/__init__.py:609:    _Cursor__exhaust           = SynchroProperty()
      synchro/__init__.py:610:    _Cursor__max_await_time_ms = SynchroProperty()
      synchro/__init__.py:611:    _Cursor__max_time_ms       = SynchroProperty()
      synchro/__init__.py:612:    _Cursor__query_flags       = SynchroProperty()
      synchro/__init__.py:613:    _Cursor__query_spec        = SynchroProperty()
      synchro/__init__.py:614:    _Cursor__retrieved         = SynchroProperty()
      synchro/__init__.py:615:    _Cursor__spec              = SynchroProperty()
      test/asyncio_tests/test_asyncio_cursor.py:139:        cursor.delegate._Cursor__id = bson.int64.Int64(1234)
      test/asyncio_tests/test_asyncio_cursor.py:339:                self.assertFalse(cursor.delegate._Cursor__killed)
      test/tornado_tests/test_motor_cursor.py:143:        cursor.delegate._Cursor__id = bson.int64.Int64(1234)
      test/tornado_tests/test_motor_cursor.py:314:                self.assertFalse(cursor.delegate._Cursor__killed)
      

      https://github.com/mongodb/motor/blob/2.5.0/motor/core.py#L1518-L1525

      We should change motor (and pymongo itself if needed) to not use any pymongo internals. I was able to cleanup some of this code in MOTOR-781 but there are still some remaining private apis used as show above. Another example is Cursor._refresh:

      class AgnosticBaseCursor(AgnosticBase):
          ...
          _refresh      = AsyncRead()
      

      https://github.com/mongodb/motor/blob/2.5.0/motor/core.py#L1126

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

              Created:
              Updated:
              Resolved: