code: def to_list(self, length):
          
          if length is not None:
              if not isinstance(length, int):
                  raise TypeError('length must be an int, not %r' % length)
              elif length < 0:
                  raise ValueError('length must be non-negative')
  
          if self._query_flags() & _QUERY_OPTIONS['tailable_cursor']:
              raise pymongo.errors.InvalidOperation(
                  "Can't call to_list on tailable cursor")
  
          future = self._framework.get_future(self.get_io_loop())
  
          if not self.alive:
              future.set_result([])
          else:
              the_list = []
              self._framework.add_future(
                  self.get_io_loop(),
                  self._get_more(),
                  self._to_list, length, the_list, future)
  
          return future
docs: Get a list of documents.
  
          .. testsetup:: to_list
  
            MongoClient().test.test_collection.delete_many({})
            MongoClient().test.test_collection.insert_many([{'_id': i} for i in range(4)])
  
            from tornado import ioloop
  
          .. doctest:: to_list
  
            >>> from motor.motor_tornado import MotorClient
            >>> collection = MotorClient().test.test_collection
            >>>
            >>> @gen.coroutine
            ... def f():
            ...     cursor = collection.find().sort([('_id', 1)])
            ...     docs = yield cursor.to_list(length=2)
            ...     while docs:
            ...         print(docs)
            ...         docs = yield cursor.to_list(length=2)
            ...
            ...     print('done')
            ...
            >>> ioloop.IOLoop.current().run_sync(f)
            [{'_id': 0}, {'_id': 1}]
            [{'_id': 2}, {'_id': 3}]
            done
  
          :Parameters:
           - `length`: maximum number of documents to return for this call, or
             None
  
           Returns a Future.
  
          .. versionchanged:: 2.0
             No longer accepts a callback argument.
  
          .. versionchanged:: 0.2
             `callback` must be passed as a keyword argument, like
             ``to_list(10, callback=callback)``, and the
             `length` parameter is no longer optional.