当前位置: 首页>>代码示例>>Python>>正文


Python helpers._check_command_response方法代码示例

本文整理汇总了Python中pymongo.helpers._check_command_response方法的典型用法代码示例。如果您正苦于以下问题:Python helpers._check_command_response方法的具体用法?Python helpers._check_command_response怎么用?Python helpers._check_command_response使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymongo.helpers的用法示例。


在下文中一共展示了helpers._check_command_response方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: write_command

# 需要导入模块: from pymongo import helpers [as 别名]
# 或者: from pymongo.helpers import _check_command_response [as 别名]
def write_command(self, request_id, msg):
        """Send "insert" etc. command, returning response as a dict.

        Can raise ConnectionFailure or OperationFailure.

        :Parameters:
          - `request_id`: an int.
          - `msg`: bytes, the command message.
        """
        self.send_message(msg, 0)
        response = helpers._unpack_response(self.receive_message(1, request_id))
        assert response['number_returned'] == 1
        result = response['data'][0]

        # Raises NotMasterError or OperationFailure.
        helpers._check_command_response(result)
        return result 
开发者ID:jruaux,项目名称:mongodb-monitoring,代码行数:19,代码来源:pool.py

示例2: write_command

# 需要导入模块: from pymongo import helpers [as 别名]
# 或者: from pymongo.helpers import _check_command_response [as 别名]
def write_command(self, request_id: int, msg: bytes) -> dict:
        response_future = asyncio.Future(loop=self.loop)
        self.__request_futures[request_id] = response_future

        self.send_message(msg)

        response_data = await response_future
        response = helpers._unpack_response(response_data)
        assert response['number_returned'] == 1

        result = response['data'][0]

        # Raises NotMasterError or OperationFailure.
        helpers._check_command_response(result)
        return result 
开发者ID:ZeoAlliance,项目名称:aiomongo,代码行数:17,代码来源:connection.py

示例3: _refresh

# 需要导入模块: from pymongo import helpers [as 别名]
# 或者: from pymongo.helpers import _check_command_response [as 别名]
def _refresh(self) -> None:
        """Refreshes the cursor with more data from the server.

        Returns the length of self.__data after refresh. Will exit early if
        self.__data is already non-empty. Raises OperationFailure when the
        cursor cannot be refreshed due to an error on the query.
        """
        if len(self.__data) or self.__killed:
            return len(self.__data)

        if self.__id:  # Get More
            dbname, collname = self.__ns.split('.', 1)

            try:
                data = await self.__connection.perform_operation(
                    _GetMore(dbname,
                             collname,
                             self.__batch_size,
                             self.__id,
                             self.__collection.codec_options))
            except EOFError:
                self.__killed = True
                raise

            try:
                doc = helpers._unpack_response(data,
                                               self.__id,
                                               self.__collection.codec_options)
                helpers._check_command_response(doc['data'][0])
            except OperationFailure:
                self.__killed = True

                raise

            cursor = doc['data'][0]['cursor']
            documents = cursor['nextBatch']
            self.__id = cursor['id']
            self.__retrieved += len(documents)

            if self.__id == 0:
                self.__killed = True
            self.__data = deque(documents)

        else:  # Cursor id is zero nothing else to return
            self.__killed = True

        return len(self.__data) 
开发者ID:ZeoAlliance,项目名称:aiomongo,代码行数:49,代码来源:command_cursor.py


注:本文中的pymongo.helpers._check_command_response方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。