def f(c, a, b): s = Scheduler((c.ip, c.port), loop=loop) yield s._sync_center() done = s.start() sched, report = Queue(), Queue(); s.handle_queues(sched, report) msg = yield report.get(); assert msg['op'] == 'stream-start' p = TextProgressBar([], scheduler=s) p.start() assert p.status == 'finished' check_bar_completed(capsys)
def test_TextProgressBar_sync(loop, capsys): with cluster() as (c, [a, b]): with Executor(('127.0.0.1', c['port']), loop=loop) as e: f = e.submit(lambda: 1) g = e.submit(lambda: 2) p = TextProgressBar([f, g]) assert p.all_keys == {f.key, g.key} p.start() # assert p in e.scheduler.plugins assert p.scheduler is e.scheduler f.result() g.result() assert not p.keys sys.stdout.flush() check_bar_completed(capsys) assert len(p.all_keys) == 2 h = e.submit(lambda x, y: x / y, 1, 0) p = TextProgressBar([h]) p.start() h.exception() with pytest.raises(AssertionError): check_bar_completed(capsys)