• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python message.kill_cursors函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pymongo.message.kill_cursors函数的典型用法代码示例。如果您正苦于以下问题:Python kill_cursors函数的具体用法?Python kill_cursors怎么用?Python kill_cursors使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: _process_kill_cursors_queue

    def _process_kill_cursors_queue(self):
        """Process any pending kill cursors requests."""
        address_to_cursor_ids = defaultdict(list)

        # Other threads or the GC may append to the queue concurrently.
        while True:
            try:
                address, cursor_ids = self.__kill_cursors_queue.pop()
            except IndexError:
                break

            address_to_cursor_ids[address].extend(cursor_ids)

        # Don't re-open topology if it's closed and there's no pending cursors.
        if address_to_cursor_ids:
            topology = self._get_topology()
            for address, cursor_ids in address_to_cursor_ids.items():
                try:
                    if address:
                        server = topology.select_server_by_address(address)
                    else:
                        # Application called close_cursor() with no address.
                        server = topology.select_server(
                            writable_server_selector)

                    server.send_message(message.kill_cursors(cursor_ids),
                                        self.__all_credentials)
                except ConnectionFailure as exc:
                    warnings.warn("couldn't close cursor on %s: %s"
                                  % (address, exc))
开发者ID:ToontownBattlefront,项目名称:Toontown-Battlefront,代码行数:30,代码来源:mongo_client.py


示例2: _process_kill_cursors_queue

    def _process_kill_cursors_queue(self):
        """Process any pending kill cursors requests."""
        address_to_cursor_ids = defaultdict(list)

        # Other threads or the GC may append to the queue concurrently.
        while True:
            try:
                address, cursor_ids = self.__kill_cursors_queue.pop()
            except IndexError:
                break

            address_to_cursor_ids[address].extend(cursor_ids)

        # Don't re-open topology if it's closed and there's no pending cursors.
        if address_to_cursor_ids:
            publish = monitoring.enabled()
            topology = self._get_topology()
            for address, cursor_ids in address_to_cursor_ids.items():
                try:
                    if address:
                        # address could be a tuple or _CursorAddress, but
                        # select_server_by_address needs (host, port).
                        server = topology.select_server_by_address(
                            tuple(address))
                    else:
                        # Application called close_cursor() with no address.
                        server = topology.select_server(
                            writable_server_selector)

                    if publish:
                        start = datetime.datetime.now()
                    data = message.kill_cursors(cursor_ids)
                    if publish:
                        duration = datetime.datetime.now() - start
                        try:
                            dbname, collname = address.namespace.split(".", 1)
                        except AttributeError:
                            dbname = collname = 'OP_KILL_CURSORS'
                        command = SON([('killCursors', collname),
                                       ('cursors', cursor_ids)])
                        monitoring.publish_command_start(
                            command, dbname, data[0], address)
                        start = datetime.datetime.now()
                    server.send_message(data, self.__all_credentials)
                    if publish:
                        duration = (datetime.datetime.now() - start) + duration
                        # OP_KILL_CURSORS returns no reply, fake one.
                        reply = {'cursorsUnknown': cursor_ids, 'ok': 1}
                        monitoring.publish_command_success(
                            duration, reply, 'killCursors', data[0], address)

                except ConnectionFailure as exc:
                    warnings.warn("couldn't close cursor on %s: %s"
                                  % (address, exc))
开发者ID:bjori,项目名称:mongo-python-driver,代码行数:54,代码来源:mongo_client.py


示例3: kill_cursors

    def kill_cursors(self, cursor_ids):
        """Send a kill cursors message with the given ids.

        Raises :class:`TypeError` if `cursor_ids` is not an instance of
        ``list``.

        :Parameters:
          - `cursor_ids`: list of cursor ids to kill
        """
        if not isinstance(cursor_ids, list):
            raise TypeError("cursor_ids must be a list")
        return self._send_message(message.kill_cursors(cursor_ids))
开发者ID:namlook,项目名称:mongo-python-driver,代码行数:12,代码来源:connection.py


示例4: close_cursor

    def close_cursor(self, cursor_id, _conn_id):
        """Close a single database cursor.

        Raises :class:`TypeError` if `cursor_id` is not an instance of
        ``(int, long)``. What closing the cursor actually means
        depends on this connection's cursor manager.

        :Parameters:
          - `cursor_id`: id of cursor to close
        """
        if not isinstance(cursor_id, (int, long)):
            raise TypeError("cursor_id must be an instance of (int, long)")

        self._send_message(message.kill_cursors([cursor_id]), _connection_to_use=_conn_id)
开发者ID:ananim,项目名称:mongo-python-driver,代码行数:14,代码来源:replica_set_connection.py


示例5: _process_kill_cursors_queue

    def _process_kill_cursors_queue(self):
        """Process any pending kill cursors requests."""
        address_to_cursor_ids = defaultdict(list)

        # Other threads or the GC may append to the queue concurrently.
        while True:
            try:
                address, cursor_ids = self.__kill_cursors_queue.pop()
            except IndexError:
                break

            address_to_cursor_ids[address].extend(cursor_ids)

        # Don't re-open topology if it's closed and there's no pending cursors.
        if address_to_cursor_ids:
            listeners = self._event_listeners
            publish = listeners.enabled_for_commands
            topology = self._get_topology()
            for address, cursor_ids in address_to_cursor_ids.items():
                try:
                    if address:
                        # address could be a tuple or _CursorAddress, but
                        # select_server_by_address needs (host, port).
                        server = topology.select_server_by_address(
                            tuple(address))
                    else:
                        # Application called close_cursor() with no address.
                        server = topology.select_server(
                            writable_server_selector)

                    try:
                        namespace = address.namespace
                        db, coll = namespace.split('.', 1)
                    except AttributeError:
                        namespace = None
                        db = coll = "OP_KILL_CURSORS"

                    spec = SON([('killCursors', coll),
                                ('cursors', cursor_ids)])
                    with server.get_socket(self.__all_credentials) as sock_info:
                        if (sock_info.max_wire_version >= 4 and
                                namespace is not None):
                            sock_info.command(db, spec)
                        else:
                            if publish:
                                start = datetime.datetime.now()
                            request_id, msg = message.kill_cursors(cursor_ids)
                            if publish:
                                duration = datetime.datetime.now() - start
                                listeners.publish_command_start(
                                    spec, db, request_id, address)
                                start = datetime.datetime.now()

                            try:
                                sock_info.send_message(msg, 0)
                            except Exception as exc:
                                if publish:
                                    dur = ((datetime.datetime.now() - start)
                                           + duration)
                                    listeners.publish_command_failure(
                                        dur, message._convert_exception(exc),
                                        'killCursors', request_id, address)
                                raise

                            if publish:
                                duration = ((datetime.datetime.now() - start)
                                            + duration)
                                # OP_KILL_CURSORS returns no reply, fake one.
                                reply = {'cursorsUnknown': cursor_ids, 'ok': 1}
                                listeners.publish_command_success(
                                    duration, reply, 'killCursors', request_id,
                                    address)

                except ConnectionFailure as exc:
                    warnings.warn("couldn't close cursor on %s: %s"
                                  % (address, exc))
开发者ID:Alpus,项目名称:Eth,代码行数:76,代码来源:mongo_client.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python message.query函数代码示例发布时间:2022-05-27
下一篇:
Python message.get_more函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap