Exemplo n.º 1
0
def test_ConcurrentJobQueue():
    done = []
    with ghcloneall.ConcurrentJobQueue(2) as queue:
        queue.add(MockTask(1, done))
        queue.add(MockTask(2, done))
        queue.add(MockTask(3, done))
    assert set(done) == {1, 2, 3}
Exemplo n.º 2
0
def test_ConcurrentJobQueue_can_be_interrupted(monkeypatch):
    monkeypatch.setattr(ghcloneall.futures, 'wait', raise_keyboard_interrupt)
    done = []
    with pytest.raises(KeyboardInterrupt):
        with ghcloneall.ConcurrentJobQueue(2) as queue:
            queue.add(MockTask(1, done))
            queue.add(MockTask(2, done))
            queue.add(MockTask(3, done))
    assert set(done) == {1, 2, -3}