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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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
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