本文整理汇总了Python中app.master.cluster_master.ClusterMaster._disconnect_non_heartbeating_slaves方法的典型用法代码示例。如果您正苦于以下问题:Python ClusterMaster._disconnect_non_heartbeating_slaves方法的具体用法?Python ClusterMaster._disconnect_non_heartbeating_slaves怎么用?Python ClusterMaster._disconnect_non_heartbeating_slaves使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.master.cluster_master.ClusterMaster
的用法示例。
在下文中一共展示了ClusterMaster._disconnect_non_heartbeating_slaves方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_heartbeat_disconnects_unresponsive_slave
# 需要导入模块: from app.master.cluster_master import ClusterMaster [as 别名]
# 或者: from app.master.cluster_master.ClusterMaster import _disconnect_non_heartbeating_slaves [as 别名]
def test_heartbeat_disconnects_unresponsive_slave(self, slave_alive, seconds_since_last_heartbeat):
last_heartbeat_time = self._mock_current_datetime - timedelta(seconds=seconds_since_last_heartbeat)
master = ClusterMaster()
mock_slave = Mock()
self.patch('app.master.cluster_master.Slave', new=lambda *args: mock_slave)
master.connect_slave('slave_url', 1)
mock_slave.is_alive.return_value = slave_alive
mock_slave.get_last_heartbeat_time.return_value = last_heartbeat_time
master._disconnect_non_heartbeating_slaves()
if slave_alive and seconds_since_last_heartbeat == 1000:
self.assertEqual(mock_slave.mark_dead.call_count, 1, 'master disconnects unresponsive slave')
else:
self.assertEqual(mock_slave.mark_dead.call_count, 0,
'master should not disconnect a dead or responsive slave')