Exemple #1
0
         position=(random.randint(-10, 10), random.randint(-10, 10)),
         lock=printlock) for i in range(len(ports))
]

if __name__ == "__main__":
    c = CacheClient(nodes=[node.port for node in nodes])

    threads = [Thread(target=node.serve, args=()) for node in nodes]
    for thread in threads:
        thread.start()

    time.sleep(2)
    c.getDistances()
    time.sleep(7)
    json = '{"a": 123, "b": 75}'
    c.writeCache('dolphin', json)

    json = "{'a': 1729, 'b': 540}"
    c.writeCache('cow', json)

    json = "{'a': '-1^\\frac{1}{2}', 'b': 'e'}"
    c.writeCache('elephant', json)

    json = "{'a': 1, 'b': 'apple', 'c': 'triangle'}"
    c.writeCache('dog', json)

    json = "{'a': 1337}"
    c.writeCache('cat', json)

    dol = c.readCache('dolphin')
    print("Value of dolphin is ", dol)