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


Python Client.waitForCommands方法代码示例

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


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

示例1: main

# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import waitForCommands [as 别名]
def main():

    # Establish the server cluster
    s1 = Server()
    s2 = Server()
    s3 = Server()
    s4 = Server()
    s5 = Server()

    s1.setNeighbors([s2, s3, s4, s5])
    s2.setNeighbors([s1, s3, s4, s5])
    s3.setNeighbors([s2, s1, s4, s5])
    s4.setNeighbors([s2, s3, s1, s5])
    s5.setNeighbors([s2, s3, s4, s1])

    t1 = Thread(target=s1.electionTimeout)
    t1.start()
    time.sleep(5)
    t2 = Thread(target=s2.electionTimeout)
    t2.start()
    t3 = Thread(target=s3.electionTimeout)
    t3.start()
    t4 = Thread(target=s4.electionTimeout)
    t4.start()
    t5 = Thread(target=s5.electionTimeout)
    t5.start()

    # Connect the client to the cluster leader
    c1 = Client()
    c1.connectClientToLeader(s2.neighbors)

    # Use the command line
    c1.waitForCommands()
开发者ID:gddmkr42171822,项目名称:csci5673,代码行数:35,代码来源:Main.py

示例2: testClientLoop

# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import waitForCommands [as 别名]
def testClientLoop():
    # Establish cluster
    s1 = Server()
    s2 = Server()
    s3 = Server()
    
    # Set cluster membership
    s1.setNeighbors([s2, s3])
    s2.setNeighbors([s1, s3])
    s3.setNeighbors([s1, s2])
    
    # Create cluster leader
    # Request an election
    s3.requestVotes()
    
    # Connect the client to the cluster leader through a non-leader
    c1 = Client()
    c1.connectClientToLeader(s3.neighbors)
    
    # Use the command line
    c1.waitForCommands()
开发者ID:gddmkr42171822,项目名称:csci5673,代码行数:23,代码来源:ClientTest.py

示例3: testClientLoopWithTimeout

# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import waitForCommands [as 别名]
def testClientLoopWithTimeout():
    s1 = Server()
    s2 = Server()
    s3 = Server()
    
    s1.setNeighbors([s2, s3])
    s2.setNeighbors([s1, s3])
    s3.setNeighbors([s1, s2])
    
    t1 = Thread(target=s1.electionTimeout)
    t1.start()
    time.sleep(5)
    t2 = Thread(target=s2.electionTimeout)
    t2.start()
    t3 = Thread(target=s3.electionTimeout)
    t3.start()
    
    # Connect the client to the cluster leader through a non-leader
    c1 = Client()
    c1.connectClientToLeader(s2.neighbors)
    
    # Use the command line
    c1.waitForCommands()
开发者ID:gddmkr42171822,项目名称:csci5673,代码行数:25,代码来源:ClientTest.py


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