wjddn279 commented on code in PR #58365:
URL: https://github.com/apache/airflow/pull/58365#discussion_r2560236372
##########
airflow-core/tests/unit/executors/test_local_executor.py:
##########
@@ -90,38 +110,33 @@ def fake_supervise(ti, **kwargs):
assert executor.result_queue.empty()
- with spy_on(executor._spawn_worker) as spawn_worker:
- for ti in success_tis:
- executor.queue_workload(
- workloads.ExecuteTask(
- token="",
- ti=ti,
- dag_rel_path="some/path",
- log_path=None,
- bundle_info=dict(name="hi", version="hi"),
- ),
- session=mock.MagicMock(spec=Session),
- )
-
+ for ti in success_tis:
executor.queue_workload(
workloads.ExecuteTask(
token="",
- ti=fail_ti,
+ ti=ti,
dag_rel_path="some/path",
log_path=None,
bundle_info=dict(name="hi", version="hi"),
),
session=mock.MagicMock(spec=Session),
)
- # Process queued workloads to trigger worker spawning
- executor._process_workloads(list(executor.queued_tasks.values()))
+ executor.queue_workload(
+ workloads.ExecuteTask(
+ token="",
+ ti=fail_ti,
+ dag_rel_path="some/path",
+ log_path=None,
+ bundle_info=dict(name="hi", version="hi"),
+ ),
+ session=mock.MagicMock(spec=Session),
+ )
- executor.end()
+ # Process queued workloads to trigger worker spawning
+ executor._process_workloads(list(executor.queued_tasks.values()))
- expected = 2
- # Depending on how quickly the tasks run, we might not need to
create all the workers we could
- assert 1 <= len(spawn_worker.calls) <= expected
Review Comment:
Sure. Since `spawn_worker` can be executed inside `executor.start()`, it
should be enough to move just that part into the `with spy_on` block.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]