@pytest.fixture(autouse=True)
    def per_test(self):
        self.processor_agent = None
        yield
        if self.processor_agent:
            self.processor_agent.end()
    def test_error_when_waiting_in_async_mode(self, tmp_path):
        self.processor_agent = DagFileProcessorAgent(
            dag_directory=tmp_path,
            max_runs=1,
            processor_timeout=datetime.timedelta(1),
            dag_ids=[],
            pickle_dags=False,
            async_mode=True,
        )
        self.processor_agent.start()
        with pytest.raises(RuntimeError, match="wait_until_finished should only be called in sync_mode"):
            self.processor_agent.wait_until_finished()
    def test_default_multiprocessing_behaviour(self, tmp_path):