コード例 #1
0
def test_timeout(c, s, a, b):
    v = Variable('v')

    start = time()
    with pytest.raises(gen.TimeoutError):
        yield v._get(timeout=0.1)
    assert time() - start < 0.5
コード例 #2
0
def test_queue_with_data(c, s, a, b):
    x = Variable('x')
    xx = Variable('x')
    assert x.client is c

    yield x._set([1, 'hello'])
    data = yield xx._get()

    assert data == [1, 'hello']
コード例 #3
0
def test_timeout_get(c, s, a, b):
    v = Variable('v')

    tornado_future = v._get()

    vv = Variable('v')
    yield vv._set(1)

    result = yield tornado_future
    assert result == 1
コード例 #4
0
def test_hold_futures(s, a, b):
    c1 = yield Client(s.address, asynchronous=True)
    future = c1.submit(lambda x: x + 1, 10)
    x1 = Variable('x')
    yield x1._set(future)
    del x1
    yield c1._shutdown()

    yield gen.sleep(0.1)

    c2 = yield Client(s.address, asynchronous=True)
    x2 = Variable('x')
    future2 = yield x2._get()
    result = yield future2

    assert result == 11
    yield c2._shutdown()
コード例 #5
0
ファイル: test_variable.py プロジェクト: manishvishnoi2/DM3
async def test_cleanup(c, s, a, b):
    v = Variable("v")
    vv = Variable("v")

    x = c.submit(lambda x: x + 1, 10)
    y = c.submit(lambda x: x + 1, 20)
    x_key = x.key

    await v.set(x)
    del x
    await gen.sleep(0.1)

    t_future = xx = asyncio.ensure_future(vv._get())
    await gen.sleep(0)
    asyncio.ensure_future(v.set(y))

    future = await t_future
    assert future.key == x_key
    result = await future
    assert result == 11
コード例 #6
0
def test_cleanup(c, s, a, b):
    v = Variable('v')
    vv = Variable('v')

    x = c.submit(lambda x: x + 1, 10)
    y = c.submit(lambda x: x + 1, 20)
    x_key = x.key

    yield v.set(x)
    del x
    yield gen.sleep(0.1)

    t_future = xx = vv._get()
    yield gen.moment
    v._set(y)

    future = yield t_future
    assert future.key == x_key
    result = yield future
    assert result == 11
コード例 #7
0
ファイル: test_variable.py プロジェクト: tomMoral/distributed
def test_cleanup(c, s, a, b):
    v = Variable('v')
    vv = Variable('v')

    x = c.submit(lambda x: x + 1, 10)
    y = c.submit(lambda x: x + 1, 20)
    x_key = x.key

    yield v.set(x)
    del x
    yield gen.sleep(0.1)

    t_future = xx = vv._get()
    yield gen.moment
    v._set(y)

    future = yield t_future
    assert future.key == x_key
    result = yield future
    assert result == 11
コード例 #8
0
def test_variable(c, s, a, b):
    x = Variable('x')
    xx = Variable('x')
    assert x.client is c

    future = c.submit(inc, 1)

    yield x._set(future)
    future2 = yield xx._get()
    assert future.key == future2.key

    del future, future2

    yield gen.sleep(0.1)
    assert s.task_state  # future still present

    x.delete()

    start = time()
    while s.task_state:
        yield gen.sleep(0.01)
        assert time() < start + 5