Exemplo n.º 1
0
def test_sharedness_of_a_darray():
    """
    Test if the double buffered array is actually shared between two processes.
    """
    parity = SharedArray.SharedNumpyArray((1, ), np.uint32)
    Array = SharedArray.DoubleBufferedSharedNumpyArray((10, 10), np.float,
                                                       parity)
    p = multiprocessing.Process(target=worker_test_sharedness_of_a_darray,
                                args=(Array, parity))
    p.start()
    p.join()
    assert (Array[5, 5] == 15)
    parity[0] = 0
    assert (Array[5, 5] == 10)
Exemplo n.º 2
0
def test_pickling_darray(tmpdir):
    """
    Pickles and unpickles a double buffered shared array
    """
    parity = SharedArray.SharedNumpyArray((1, ), np.uint32)
    A = SharedArray.DoubleBufferedSharedNumpyArray((10, 10), np.float, parity)
    A[1, 1] = 15
    parity[0] = 1
    A[1, 1] = 12
    save({"array": A, "parity": parity}, str(tmpdir) + "/test.p.gz")
    ddict = load(str(tmpdir) + "/test.p.gz")
    B = ddict["array"]
    parity = ddict["parity"]
    assert (B[1, 1] == 12)
    parity[0] = 0
    assert (B[1, 1] == 15)