Esempio n. 1
0
def test_progressbar_done(loop):
    with cluster() as (s, [a, b]):
        with Client(s['address'], loop=loop) as c:
            L = [c.submit(inc, i) for i in range(5)]
            wait(L)
            p = ProgressWidget(L)
            sync(loop, p.listen)
            assert p.status == 'finished'
            assert p.bar.value == 1.0
            assert p.bar.bar_style == 'success'
            assert 'Finished' in p.elapsed_time.value

            f = c.submit(throws, L)
            wait([f])

            p = ProgressWidget([f])
            sync(loop, p.listen)
            assert p.status == 'error'
            assert p.bar.value == 0.0
            assert p.bar.bar_style == 'danger'
            assert 'Exception' in p.elapsed_time.value

            try:
                throws(1)
            except Exception as e:
                assert repr(e) in p.elapsed_time.value
Esempio n. 2
0
    async def f():
        results = await All([inc(i) for i in range(10)])
        assert results == list(range(1, 11))

        start = time()
        for tasks in [[throws(), slow()], [slow(), throws()]]:
            try:
                await All(tasks)
                assert False
            except ZeroDivisionError:
                pass
            end = time()
            assert end - start < 10
Esempio n. 3
0
    def f():

        results = yield All(*[inc(i) for i in range(10)])
        assert results == list(range(1, 11))

        start = time()
        for tasks in [[throws(), slow()], [slow(), throws()]]:
            try:
                yield All(tasks)
                assert False
            except ZeroDivisionError:
                pass
            end = time()
            assert end - start < 10
Esempio n. 4
0
def test_multi_progressbar_widget(c, s, a, b):
    x1 = c.submit(inc, 1)
    x2 = c.submit(inc, x1)
    x3 = c.submit(inc, x2)
    y1 = c.submit(dec, x3)
    y2 = c.submit(dec, y1)
    e = c.submit(throws, y2)
    other = c.submit(inc, 123)
    yield wait([other, e])

    p = MultiProgressWidget([e.key], scheduler=s.address, complete=True)
    yield p.listen()

    assert p.bars["inc"].value == 1.0
    assert p.bars["dec"].value == 1.0
    assert p.bars["throws"].value == 0.0
    assert "3 / 3" in p.bar_texts["inc"].value
    assert "2 / 2" in p.bar_texts["dec"].value
    assert "0 / 1" in p.bar_texts["throws"].value

    assert p.bars["inc"].bar_style == "success"
    assert p.bars["dec"].bar_style == "success"
    assert p.bars["throws"].bar_style == "danger"

    assert p.status == "error"
    assert "Exception" in p.elapsed_time.value

    try:
        throws(1)
    except Exception as e:
        assert repr(e) in p.elapsed_time.value

    capacities = [
        int(
            re.search(r"\d+ / \d+",
                      row.children[0].value).group().split(" / ")[1])
        for row in p.bar_widgets.children
    ]
    assert sorted(capacities, reverse=True) == capacities
Esempio n. 5
0
def test_multi_progressbar_widget(c, s, a, b):
    x1 = c.submit(inc, 1)
    x2 = c.submit(inc, x1)
    x3 = c.submit(inc, x2)
    y1 = c.submit(dec, x3)
    y2 = c.submit(dec, y1)
    e = c.submit(throws, y2)
    other = c.submit(inc, 123)
    yield wait([other, e])

    p = MultiProgressWidget([e.key], scheduler=(s.ip, s.port), complete=True)
    yield p.listen()

    assert p.bars['inc'].value == 1.0
    assert p.bars['dec'].value == 1.0
    assert p.bars['throws'].value == 0.0
    assert '3 / 3' in p.bar_texts['inc'].value
    assert '2 / 2' in p.bar_texts['dec'].value
    assert '0 / 1' in p.bar_texts['throws'].value

    assert p.bars['inc'].bar_style == 'success'
    assert p.bars['dec'].bar_style == 'success'
    assert p.bars['throws'].bar_style == 'danger'

    assert p.status == 'error'
    assert 'Exception' in p.elapsed_time.value

    try:
        throws(1)
    except Exception as e:
        assert repr(e) in p.elapsed_time.value

    capacities = [
        int(
            re.search(r'\d+ / \d+',
                      row.children[0].value).group().split(' / ')[1])
        for row in p.bar_widgets.children
    ]
    assert sorted(capacities, reverse=True) == capacities
Esempio n. 6
0
def test_progressbar_done(client):
    L = [client.submit(inc, i) for i in range(5)]
    wait(L)
    p = ProgressWidget(L)
    client.sync(p.listen)
    assert p.status == "finished"
    assert p.bar.value == 1.0
    assert p.bar.bar_style == "success"
    assert "Finished" in p.elapsed_time.value

    f = client.submit(throws, L)
    wait([f])

    p = ProgressWidget([f])
    client.sync(p.listen)
    assert p.status == "error"
    assert p.bar.value == 0.0
    assert p.bar.bar_style == "danger"
    assert "Exception" in p.elapsed_time.value

    try:
        throws(1)
    except Exception as e:
        assert repr(e) in p.elapsed_time.value
Esempio n. 7
0
def test_progressbar_done(client):
    L = [client.submit(inc, i) for i in range(5)]
    wait(L)
    p = ProgressWidget(L)
    client.sync(p.listen)
    assert p.status == 'finished'
    assert p.bar.value == 1.0
    assert p.bar.bar_style == 'success'
    assert 'Finished' in p.elapsed_time.value

    f = client.submit(throws, L)
    wait([f])

    p = ProgressWidget([f])
    client.sync(p.listen)
    assert p.status == 'error'
    assert p.bar.value == 0.0
    assert p.bar.bar_style == 'danger'
    assert 'Exception' in p.elapsed_time.value

    try:
        throws(1)
    except Exception as e:
        assert repr(e) in p.elapsed_time.value
Esempio n. 8
0
def test_multi_progressbar_widget(c, s, a, b):
    x1 = c.submit(inc, 1)
    x2 = c.submit(inc, x1)
    x3 = c.submit(inc, x2)
    y1 = c.submit(dec, x3)
    y2 = c.submit(dec, y1)
    e = c.submit(throws, y2)
    other = c.submit(inc, 123)
    yield wait([other, e])

    p = MultiProgressWidget([e.key], scheduler=s.address, complete=True)
    yield p.listen()

    assert p.bars['inc'].value == 1.0
    assert p.bars['dec'].value == 1.0
    assert p.bars['throws'].value == 0.0
    assert '3 / 3' in p.bar_texts['inc'].value
    assert '2 / 2' in p.bar_texts['dec'].value
    assert '0 / 1' in p.bar_texts['throws'].value

    assert p.bars['inc'].bar_style == 'success'
    assert p.bars['dec'].bar_style == 'success'
    assert p.bars['throws'].bar_style == 'danger'

    assert p.status == 'error'
    assert 'Exception' in p.elapsed_time.value

    try:
        throws(1)
    except Exception as e:
        assert repr(e) in p.elapsed_time.value

    capacities = [int(re.search(r'\d+ / \d+', row.children[0].value)
                      .group().split(' / ')[1])
                  for row in p.bar_widgets.children]
    assert sorted(capacities, reverse=True) == capacities
Esempio n. 9
0
async def test_all_exceptions_logging():
    async def throws():
        raise Exception("foo1234")

    with captured_logger("") as sio:
        try:
            await All([throws() for _ in range(5)], quiet_exceptions=Exception)
        except Exception:
            pass

        import gc

        gc.collect()
        await asyncio.sleep(0.1)

    assert "foo1234" not in sio.getvalue()
Esempio n. 10
0
def test_all_exceptions_logging():
    @gen.coroutine
    def throws():
        raise Exception('foo1234')

    with captured_logger('') as sio:
        try:
            yield All([throws() for _ in range(5)], quiet_exceptions=Exception)
        except Exception:
            pass

        import gc
        gc.collect()
        yield gen.sleep(0.1)

    assert 'foo1234' not in sio.getvalue()
Esempio n. 11
0
def test_all_exceptions_logging():
    @gen.coroutine
    def throws():
        raise Exception('foo1234')

    with captured_logger('') as sio:
        try:
            yield All([throws() for _ in range(5)],
                      quiet_exceptions=Exception)
        except Exception:
            pass

        import gc; gc.collect()
        yield gen.sleep(0.1)

    assert 'foo1234' not in sio.getvalue()
Esempio n. 12
0
 def function2(x):
     return throws(x)
Esempio n. 13
0
 def function2(x):
     return throws(x)