예제 #1
0
    def f(c, a, b):
        e = Executor((c.ip, c.port), start=False, loop=loop)
        yield e._start()

        dsk = {('x', 0): (inc, 1), 5: (inc, 2)}

        x = yield e._get(dsk, ('x', 0))
        y = yield e._get(dsk, 5)
        assert x == 2
        assert y == 3

        yield e._shutdown()
예제 #2
0
def test_get_with_non_list_key(s, a, b):
    e = Executor((s.ip, s.port), start=False)
    yield e._start()

    dsk = {('x', 0): (inc, 1), 5: (inc, 2)}

    x = yield e._get(dsk, ('x', 0))
    y = yield e._get(dsk, 5)
    assert x == 2
    assert y == 3

    yield e._shutdown()
예제 #3
0
def test_get_with_non_list_key(s, a, b):
    e = Executor((s.ip, s.port), start=False)
    yield e._start()

    dsk = {('x', 0): (inc, 1), 5: (inc, 2)}

    x = yield e._get(dsk, ('x', 0))
    y = yield e._get(dsk, 5)
    assert x == 2
    assert y == 3

    yield e._shutdown()
예제 #4
0
    def f(c, a, b):
        e = Executor((c.ip, c.port), start=False)
        IOLoop.current().spawn_callback(e._go)
        result = yield e._get({'x': (inc, 1)}, 'x')
        assert result == 2

        result = yield e._get({'x': (inc, 1)}, ['x'])
        assert result == [2]

        result = yield e._get({}, [])
        assert result == []

        yield e._shutdown()
예제 #5
0
    def f(c, a, b):
        e = Executor((c.ip, c.port), start=False)
        IOLoop.current().spawn_callback(e._go)
        result = yield e._get({'x': (inc, 1)}, 'x')
        assert result == 2

        result = yield e._get({'x': (inc, 1)}, ['x'])
        assert result == [2]

        result = yield e._get({}, [])
        assert result == []

        yield e._shutdown()
예제 #6
0
def test_get(s, a, b):
    e = Executor((s.ip, s.port), start=False)
    yield e._start()

    result = yield e._get({'x': (inc, 1)}, 'x')
    assert result == 2

    result = yield e._get({'x': (inc, 1)}, ['x'])
    assert result == [2]

    result = yield e._get({}, [])
    assert result == []

    yield e._shutdown()
예제 #7
0
    def f(c, a, b):
        e = Executor((c.ip, c.port), start=False, loop=loop)
        yield e._start()

        result = yield e._get({'x': (inc, 1)}, 'x')
        assert result == 2

        result = yield e._get({'x': (inc, 1)}, ['x'])
        assert result == [2]

        result = yield e._get({}, [])
        assert result == []

        yield e._shutdown()
예제 #8
0
def test_get(s, a, b):
    e = Executor((s.ip, s.port), start=False)
    yield e._start()

    result = yield e._get({'x': (inc, 1)}, 'x')
    assert result == 2

    result = yield e._get({'x': (inc, 1)}, ['x'])
    assert result == [2]

    result = yield e._get({}, [])
    assert result == []

    yield e._shutdown()
예제 #9
0
def test_get_with_error(s, a, b):
    e = Executor((s.ip, s.port), start=False)
    yield e._start()

    dsk = {'x': (div, 1, 0), 'y': (inc, 'x')}
    with pytest.raises(ZeroDivisionError):
        y = yield e._get(dsk, 'y')

    yield e._shutdown()
예제 #10
0
def test_get_with_error(s, a, b):
    e = Executor((s.ip, s.port), start=False)
    yield e._start()

    dsk = {'x': (div, 1, 0), 'y': (inc, 'x')}
    with pytest.raises(ZeroDivisionError):
        y = yield e._get(dsk, 'y')

    yield e._shutdown()
예제 #11
0
    def f(c, a, b):
        e = Executor((c.ip, c.port), start=False, loop=loop)
        yield e._start()

        [x] = yield e._get({'x': (inc, 1)}, ['x'])
        import gc; gc.collect()
        assert e.refcount['x'] == 0

        yield e._shutdown()
예제 #12
0
def test_get_releases_data(s, a, b):
    e = Executor((s.ip, s.port), start=False)
    yield e._start()

    [x] = yield e._get({'x': (inc, 1)}, ['x'])
    import gc; gc.collect()
    assert e.refcount['x'] == 0

    yield e._shutdown()
예제 #13
0
def test_get_releases_data(s, a, b):
    e = Executor((s.ip, s.port), start=False)
    yield e._start()

    [x] = yield e._get({'x': (inc, 1)}, ['x'])
    import gc; gc.collect()
    assert e.refcount['x'] == 0

    yield e._shutdown()
예제 #14
0
    def f(c, a, b):
        e = Executor((c.ip, c.port), start=False, loop=loop)
        yield e._start()

        dsk = {'x': (div, 1, 0), 'y': (inc, 'x')}
        with pytest.raises(ZeroDivisionError):
            y = yield e._get(dsk, 'y')

        yield e._shutdown()
예제 #15
0
def test_submit_then_get_with_Future(s, a, b):
    e = Executor((s.ip, s.port), start=False)
    yield e._start()

    x = e.submit(slowinc, 1)
    dsk = {'y': (inc, x)}

    result = yield e._get(dsk, 'y')
    assert result == 3

    yield e._shutdown()
예제 #16
0
    def f(c, a, b):
        e = Executor((c.ip, c.port), start=False)
        IOLoop.current().spawn_callback(e._go)

        x = e.submit(slowinc, 1)
        dsk = {'y': (inc, x)}

        result = yield e._get(dsk, 'y')
        assert result == 3

        yield e._shutdown()
예제 #17
0
def test_submit_then_get_with_Future(s, a, b):
    e = Executor((s.ip, s.port), start=False)
    yield e._start()

    x = e.submit(slowinc, 1)
    dsk = {'y': (inc, x)}

    result = yield e._get(dsk, 'y')
    assert result == 3

    yield e._shutdown()
예제 #18
0
def test_aliases(s, a, b):
    e = Executor((s.ip, s.port), start=False)
    yield e._start()

    x = e.submit(inc, 1)

    dsk = {'y': x}
    result = yield e._get(dsk, 'y')
    assert result == 2

    yield e._shutdown()
예제 #19
0
def test_aliases(s, a, b):
    e = Executor((s.ip, s.port), start=False)
    yield e._start()

    x = e.submit(inc, 1)

    dsk = {'y': x}
    result = yield e._get(dsk, 'y')
    assert result == 2

    yield e._shutdown()
예제 #20
0
    def f(c, a, b):
        e = Executor((c.ip, c.port), start=False)
        IOLoop.current().spawn_callback(e._go)

        x = e.submit(slowinc, 1)
        dsk = {'y': (inc, x)}

        result = yield e._get(dsk, 'y')
        assert result == 3

        yield e._shutdown()
예제 #21
0
    def f(c, a, b):
        e = Executor((c.ip, c.port), start=False, loop=loop)
        yield e._start()

        x = e.submit(inc, 1)

        dsk = {'y': x}
        result = yield e._get(dsk, 'y')
        assert result == 2

        yield e._shutdown()
예제 #22
0
def test_restrictions_get(s, a, b):
    e = Executor((s.ip, s.port), start=False)
    yield e._start()

    dsk = {'x': 1, 'y': (inc, 'x'), 'z': (inc, 'y')}
    restrictions = {'y': {a.ip}, 'z': {b.ip}}

    result = yield e._get(dsk, ['y', 'z'], restrictions)
    assert result == [2, 3]
    assert 'y' in a.data
    assert 'z' in b.data

    yield e._shutdown()
예제 #23
0
    def f(c, a, b):
        e = Executor((c.ip, c.port), start=False)
        IOLoop.current().spawn_callback(e._go)

        dsk = {'x': 1, 'y': (inc, 'x'), 'z': (inc, 'y')}
        restrictions = {'y': {a.ip}, 'z': {b.ip}}

        result = yield e._get(dsk, 'z', restrictions)
        assert result == 3
        assert 'y' in a.data
        assert 'z' in b.data

        yield e._shutdown()
예제 #24
0
    def f(c, a, b):
        e = Executor((c.ip, c.port), start=False)
        IOLoop.current().spawn_callback(e._go)

        dsk = {'x': 1, 'y': (inc, 'x'), 'z': (inc, 'y')}
        restrictions = {'y': {a.ip}, 'z': {b.ip}}

        result = yield e._get(dsk, 'z', restrictions)
        assert result == 3
        assert 'y' in a.data
        assert 'z' in b.data

        yield e._shutdown()
예제 #25
0
def test_restrictions_get(s, a, b):
    e = Executor((s.ip, s.port), start=False)
    yield e._start()

    dsk = {'x': 1, 'y': (inc, 'x'), 'z': (inc, 'y')}
    restrictions = {'y': {a.ip}, 'z': {b.ip}}

    result = yield e._get(dsk, ['y', 'z'], restrictions)
    assert result == [2, 3]
    assert 'y' in a.data
    assert 'z' in b.data

    yield e._shutdown()
예제 #26
0
    def f(c, a, b):
        e = Executor((c.ip, c.port), start=False, loop=loop)
        yield e._start()

        dsk = {'x': 1, 'y': (inc, 'x'), 'z': (inc, 'y')}
        restrictions = {'y': {a.ip}, 'z': {b.ip}}

        result = yield e._get(dsk, 'z', restrictions)
        assert result == 3
        assert 'y' in a.data
        assert 'z' in b.data

        yield e._shutdown()
예제 #27
0
    def f(c, a, b):
        bad = ('bad-host', 8788)
        c.ncores[bad] = 4
        c.who_has['b'] = {bad}
        c.has_what[bad] = {'b'}

        e = Executor((c.ip, c.port), start=False)
        IOLoop.current().spawn_callback(e._go)

        dsk = {'a': 1, 'b': (inc, 'a'), 'c': (inc, 'b')}

        result = yield e._get(dsk, 'c')
        assert result == 3
        assert bad not in e.ncores

        yield e._shutdown()
예제 #28
0
    def f(c, a, b):
        bad = ('bad-host', 8788)
        c.ncores[bad] = 4
        c.who_has['b'] = {bad}
        c.has_what[bad] = {'b'}

        e = Executor((c.ip, c.port), start=False, loop=loop)
        yield e._start()

        dsk = {'a': 1, 'b': (inc, 'a'), 'c': (inc, 'b')}

        result = yield e._get(dsk, 'c')
        assert result == 3
        assert bad not in e.scheduler.ncores

        yield e._shutdown()
예제 #29
0
def test_missing_worker(s, a, b):
    bad = ('bad-host', 8788)
    s.ncores[bad] = 4
    s.who_has['b'] = {bad}
    s.has_what[bad] = {'b'}

    e = Executor((s.ip, s.port), start=False)
    yield e._start()

    dsk = {'a': 1, 'b': (inc, 'a'), 'c': (inc, 'b')}

    result = yield e._get(dsk, 'c')
    assert result == 3
    assert bad not in s.ncores

    yield e._shutdown()
예제 #30
0
def test_missing_worker(s, a, b):
    bad = ('bad-host', 8788)
    s.ncores[bad] = 4
    s.who_has['b'] = {bad}
    s.has_what[bad] = {'b'}

    e = Executor((s.ip, s.port), start=False)
    yield e._start()

    dsk = {'a': 1, 'b': (inc, 'a'), 'c': (inc, 'b')}

    result = yield e._get(dsk, 'c')
    assert result == 3
    assert bad not in s.ncores

    yield e._shutdown()
예제 #31
0
    def f(c, a, b):
        bad = ('bad-host', 8788)
        c.ncores[bad] = 4
        c.who_has['b'] = {bad}
        c.has_what[bad] = {'b'}

        e = Executor((c.ip, c.port), start=False)
        IOLoop.current().spawn_callback(e._go)

        dsk = {'a': 1, 'b': (inc, 'a'), 'c': (inc, 'b')}

        result = yield e._get(dsk, 'c')
        assert result == 3
        assert bad not in e.ncores

        yield e._shutdown()
예제 #32
0
    def f(s, a, b):
        assert s.ncores == {a.address: a.ncores, b.address: b.ncores}
        e = Executor(('127.0.0.1', s.port), start=False, loop=loop)
        yield e._start()

        x = e.submit(inc, 1)
        y = e.submit(inc, 2)
        z = e.submit(add, x, y)
        result = yield x._result()
        assert result == 1 + 1

        a, b, c = yield e._scatter([1, 2, 3])
        aa, bb, xx = yield e._gather([a, b, x])
        assert (aa, bb, xx) == (1, 2, 2)

        result = yield e._get({'x': (inc, 1), 'y': (add, 'x', 10)}, 'y')
        assert result == 12
예제 #33
0
    def f(s, a, b):
        assert s.ncores == {a.address: a.ncores, b.address: b.ncores}
        e = Executor(('127.0.0.1', s.port), start=False, loop=loop)
        yield e._start()

        x = e.submit(inc, 1)
        y = e.submit(inc, 2)
        z = e.submit(add, x, y)
        result = yield x._result()
        assert result == 1 + 1

        a, b, c = yield e._scatter([1, 2, 3])
        aa, bb, xx = yield e._gather([a, b, x])
        assert (aa, bb, xx) == (1, 2, 2)

        result = yield e._get({'x': (inc, 1), 'y': (add, 'x', 10)}, 'y')
        assert result == 12