quantumlib / Stim

A fast stabilizer circuit library.
Apache License 2.0
356 stars 105 forks source link

Fix flake in sinter tests #839

Open Strilanc opened 2 months ago

Strilanc commented 2 months ago
___________________________ test_worker_finish_work ____________________________

    def test_worker_finish_work():
        handler = MockWorkHandler()

        inp = multiprocessing.Queue()
        out = multiprocessing.Queue()
        inp.cancel_join_thread()
        out.cancel_join_thread()

        worker = CollectionWorkerState(
            flush_period=-1,
            worker_id=5,
            sampler=handler,
            inp=inp,
            out=out,
            custom_error_count_key=None,
        )

        assert worker.process_messages() == 0
        _assert_drain_queue(out, [])

        ta = sinter.Task(
            circuit=stim.Circuit('H 0'),
            detector_error_model=stim.DetectorErrorModel(),
            decoder='mock',
            collection_options=sinter.CollectionOptions(max_shots=100_000_000),
            json_metadata={'a': 3},
        )
        handler.expected_task = ta
        _put_wait_not_empty(inp, ('change_job', (ta, sinter.CollectionOptions(max_errors=100_000_000), 100_000_000)))
        _put_wait_not_empty(inp, ('accept_shots', (ta.strong_id(), 10000)))
>       assert worker.process_messages() == 2
E       assert 1 == 2
E        +  where 1 = process_messages()
E        +    where process_messages = <sinter._collection._collection_worker_state.CollectionWorkerState object at 0x7f27b7e75e[50](https://github.com/quantumlib/Stim/actions/runs/11009521084/job/30569371086#step:9:51)>.process_messages

glue/sample/src/sinter/_collection/_collection_worker_test.py:166: AssertionError