def test_error_raised_when_text_fields_contain_token_indexers(max_instances_in_memory):
    """
    This tests that the MultiProcessDataLoader raises an error when num_workers > 0
    but the dataset reader doesn't implement apply_token_indexers().

    It also tests that errors raised within a worker process are propogated upwards
    to the main process, and that when that happens, all workers will be successfully
    killed.
    """

    with pytest.raises(WorkerError, match="Make sure your dataset reader's text_to_instance()"):
        loader = MultiProcessDataLoader(
            MockOldDatasetReader(),
            "this-path-doesn't-matter",
            num_workers=2,
            max_instances_in_memory=max_instances_in_memory,
            batch_size=1,
        )
        list(loader.iter_instances())
This tests that the MultiProcessDataLoader raises an error when num_workers > 0
but the dataset reader doesn't implement apply_token_indexers().

It also tests that errors raised within a worker process are propogated upwards
to the main process, and that when that happens, all workers will be successfully
killed.
tests/data/data_loaders/multiprocess_data_loader_test.py