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


Python CircusSockets.remove方法代码示例

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


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

示例1: Arbiter

# 需要导入模块: from circus.sockets import CircusSockets [as 别名]
# 或者: from circus.sockets.CircusSockets import remove [as 别名]

#.........这里部分代码省略.........

        current_socket_names = set([i.name for i in self.sockets])
        new_socket_names = set([i['name'] for i in cfg.get('sockets', [])])
        added_socket_names = new_socket_names - current_socket_names
        deleted_socket_names = current_socket_names - new_socket_names
        maybechanged_socket_names = current_socket_names - deleted_socket_names
        changed_socket_names = set([])
        watcher_names_with_changed_socket = set([])
        watcher_names_with_deleted_socket = set([])

        # get changed sockets
        for n in maybechanged_socket_names:
            s = self.get_socket(n)
            if s.cfg2dict(self.get_socket_config(cfg, n)) != s.cfg:
                changed_socket_names.add(n)

                # just delete the socket and add it again
                deleted_socket_names.add(n)
                added_socket_names.add(n)

                # Get the watchers whichs use these, so they could be deleted and added also
                for w in self.iter_watchers:
                    if 'circus.sockets.%s' % n.lower() in w.cmd:
                        watcher_names_with_changed_socket.add(w.name)

        # get deleted sockets
        for n in deleted_socket_names:
            s = self.get_socket(n)
            s.close()
            # Get the watchers whichs use these, these should not be active anymore
            for w in self.iter_watchers():
                if 'circus.sockets.%s' % n.lower() in w.cmd:
                    watcher_names_with_deleted_socket.add(w.name)
            self.sockets.remove(s)

        # get added sockets
        for n in added_socket_names:
            s = CircusSocket.load_from_config(self.get_socket_config(cfg, n))
            s.bind_and_listen()
            self.sockets.append(s)

        if added_socket_names or deleted_socket_names:
            # make sure all existing watchers get the new sockets in their attributes and get the old removed
            for watcher in self.iter_watchers():
                watcher.initialize(self.evpub_socket, self.sockets, self)

        current_watcher_names = set([i.name for i in self.iter_watchers()])
        new_watcher_names = set([i['name'] for i in cfg.get('watchers', [])])
        added_watcher_names = (new_watcher_names - current_watcher_names) | watcher_names_with_changed_socket
        deleted_watcher_names = current_watcher_names - new_watcher_names - watcher_names_with_changed_socket
        maybechanged_watcher_names = current_watcher_names - deleted_watcher_names
        changed_watcher_names = set([])

        if watcher_names_with_deleted_socket and watcher_names_with_deleted_socket not in new_watcher_names:
            raise ValueError('Watchers %s uses a socket which is deleted' % watcher_names_with_deleted_socket)

        #get changed watchers
        for n in maybechanged_watcher_names:
            w = self.get_watcher(n)
            new_cfg = w.cfg2dict(self.get_watcher_config(cfg, n))
            old_cfg = w.cfg2dict(w.cfg)  # cfg2dict is used to make sure a copy is returned
            if new_cfg != old_cfg:
                old_cfg['numprocesses'] = new_cfg['numprocesses']
                if new_cfg == old_cfg:
                    # if nothing but the number of processes is changed, just changes this
                    w.set_numprocesses(int(new_cfg['numprocesses']))
开发者ID:Jud,项目名称:circus,代码行数:70,代码来源:arbiter.py


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