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


Python KazooState.LOST属性代码示例

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


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

示例1: _lock_listener

# 需要导入模块: from kazoo.client import KazooState [as 别名]
# 或者: from kazoo.client.KazooState import LOST [as 别名]
def _lock_listener(self, state):
        """
        Listener to handle ZK disconnection/reconnection. Since I don't know of safe way to check if a lock is still in
        ZK after a reconnect, we simply release the lock and try and re-acquire it.

        Args:
            state (kazoo.client.KazooState): The state of the ZK connection

        Returns:
            None
        """

        if state in [KazooState.LOST, KazooState.SUSPENDED]:
            self._logger.warn(u'Disconnected from Zookeeper, waiting to reconnect lock for {}'.format(str(self)))
            self._locked = False
        elif state == KazooState.CONNECTED:
            self._logger.warn(
                    u'Reconnected to Zookeeper, trying to release and re-acquire lock for {}'.format(str(self)))
            self._context.zookeeper_client.handler.spawn(self._release_and_reacquire)
        else:
            self._logger.warn(u'Got unknown state "{}" from Zookeeper'.format(state)) 
开发者ID:yahoo,项目名称:panoptes,代码行数:23,代码来源:lock.py

示例2: event_listener

# 需要导入模块: from kazoo.client import KazooState [as 别名]
# 或者: from kazoo.client.KazooState import LOST [as 别名]
def event_listener(self, state):
        if state == KazooState.LOST or state == KazooState.SUSPENDED:
            logger.info('ZK state transitioned to %s. Resetting master status.', state)

            # cancel pending attempts to acquire lock which will break and leave
            # us in bad state
            self.lock.cancel()

            # make us try to re-acquire lock during next iteration when we're connected
            if self.lock.is_acquired:
                self.lock.is_acquired = False

            # make us try to rejoin the party during next iteration when we're connected
            if self.party.participating:
                self.party.participating = False

            # in the meantime we're not master
            self.is_master = None 
开发者ID:linkedin,项目名称:iris,代码行数:20,代码来源:kazoo.py

示例3: state_listener

# 需要导入模块: from kazoo.client import KazooState [as 别名]
# 或者: from kazoo.client.KazooState import LOST [as 别名]
def state_listener(self, state):
        '''
        Restarts the session if we get anything besides CONNECTED
        '''
        if state == KazooState.SUSPENDED:
            self.set_valid(False)
            self.call_error(self.BAD_CONNECTION)
        elif state == KazooState.LOST and not self.do_not_restart:
            self.threaded_start()
        elif state == KazooState.CONNECTED:
            # This is going to throw a SUSPENDED kazoo error
            # which will cause the sessions to be wiped and re established.
            # Used b/c of massive connection pool issues
            self.zoo_client.stop() 
开发者ID:istresearch,项目名称:scrapy-cluster,代码行数:16,代码来源:zookeeper_watcher.py

示例4: _on_conn_change

# 需要导入模块: from kazoo.client import KazooState [as 别名]
# 或者: from kazoo.client.KazooState import LOST [as 别名]
def _on_conn_change(self, state):

        logger.debug('state changed: {state}'.format(state=state,))

        with self.state_lock:
            if state == KazooState.LOST or state == KazooState.SUSPENDED:
                self.connected = False 
开发者ID:bsc-s2,项目名称:pykit,代码行数:9,代码来源:zktx.py

示例5: connection_listener

# 需要导入模块: from kazoo.client import KazooState [as 别名]
# 或者: from kazoo.client.KazooState import LOST [as 别名]
def connection_listener(self, state: KazooState) -> None:
        self.log.warning(f"Zookeeper connection transitioned to: {state}")
        if state == KazooState.SUSPENDED:
            self.log.warning(
                "Zookeeper connection suspended, waiting to see if it recovers."
            )
            if not self.waiting_for_reconnect:
                self.waiting_for_reconnect = True
                reconnection_checker = PaastaThread(target=self.reconnection_listener)
                reconnection_checker.daemon = True
                reconnection_checker.start()
        elif state == KazooState.LOST:
            self.log.error("Leadership lost, quitting!")
            self._terminate() 
开发者ID:Yelp,项目名称:paasta,代码行数:16,代码来源:leader.py

示例6: test_connection_listener

# 需要导入模块: from kazoo.client import KazooState [as 别名]
# 或者: from kazoo.client.KazooState import LOST [as 别名]
def test_connection_listener(self):
        with mock.patch(
            "paasta_tools.deployd.leader.PaastaThread", autospec=True
        ) as mock_paasta_thread:
            self.election.connection_listener(KazooState.CONNECTED)
            self.election.connection_listener(KazooState.SUSPENDED)
            mock_paasta_thread.assert_called_with(
                target=self.election.reconnection_listener
            )
            assert self.election.waiting_for_reconnect
            self.election.connection_listener(KazooState.LOST)
            self.mock_control.put.assert_called_with("ABORT") 
开发者ID:Yelp,项目名称:paasta,代码行数:14,代码来源:test_leader.py

示例7: session_listener

# 需要导入模块: from kazoo.client import KazooState [as 别名]
# 或者: from kazoo.client.KazooState import LOST [as 别名]
def session_listener(self, state):
        if state in [KazooState.SUSPENDED, KazooState.LOST]:
            self.cluster_watcher(None) 
开发者ID:zalando,项目名称:patroni,代码行数:5,代码来源:zookeeper.py


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