custom_server.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:krafters 作者: GianlucaBortoli 项目源码 文件源码
def main():
    with open(sys.argv[1]) as configuration_file:
        configuration = json.load(configuration_file)

    if len(sys.argv) == 3:
        test_daemon_client = xmlrpclib.ServerProxy("http://{}".format(sys.argv[2]))
        callback = partial(onUpdateFunction, test_daemon_client)
    else:
        callback = partial(noop)

    class ReplicatedValue(ExponentialBackoffResolutionStrategyMixin, SimpleSynchronizationStrategyMixin,
                          BaseReplicatedValue):
        '''
        Mixes just the resolution and synchronization strategies into the base class
        '''

    id = configuration["host"]["id"]
    state_file = "./paxos_state_{}.json".format(id)
    peers = {peer["id"]: (peer["address"], peer["port"]) for peer in configuration["peers"]}
    peers[id] = (configuration["host"]["address"], configuration["host"]["port"])
    r = ReplicatedValue(id, peers.keys(), state_file, callback)
    m = Messenger(id, peers, r)
    if len(sys.argv) == 3:
        listener = TestDaemonListener(m)
    reactor.run()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号