You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2023/09/04 18:37:22 UTC
[airflow] branch main updated: Refactor attempting loops in tests (#34055)
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 213487591b Refactor attempting loops in tests (#34055)
213487591b is described below
commit 213487591bddab66734acda85819c8e401bc652b
Author: Miroslav Šedivý <67...@users.noreply.github.com>
AuthorDate: Mon Sep 4 18:37:14 2023 +0000
Refactor attempting loops in tests (#34055)
---
tests/dag_processing/test_job_runner.py | 7 +++----
tests/datasets/test_manager.py | 7 +++----
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/tests/dag_processing/test_job_runner.py b/tests/dag_processing/test_job_runner.py
index a30c4a4b9f..ffa953f434 100644
--- a/tests/dag_processing/test_job_runner.py
+++ b/tests/dag_processing/test_job_runner.py
@@ -19,6 +19,7 @@ from __future__ import annotations
import collections
import contextlib
+import itertools
import logging
import multiprocessing
import os
@@ -833,14 +834,13 @@ class TestDagProcessorJobRunner:
# To test this behaviour we need something that continually fills the
# parent pipe's buffer (and keeps it full).
def keep_pipe_full(pipe, exit_event):
- n = 0
- while True:
+ for n in itertools.count(1):
if exit_event.is_set():
break
req = CallbackRequest(str(dag_filepath))
+ logging.info("Sending CallbackRequests %d", n)
try:
- logging.info("Sending CallbackRequests %d", n + 1)
pipe.send(req)
except TypeError:
# This is actually the error you get when the parent pipe
@@ -848,7 +848,6 @@ class TestDagProcessorJobRunner:
break
except OSError:
break
- n += 1
logging.debug(" Sent %d CallbackRequests", n)
thread = threading.Thread(target=keep_pipe_full, args=(parent_pipe, exit_event))
diff --git a/tests/datasets/test_manager.py b/tests/datasets/test_manager.py
index 10d54744b9..a5abc764a9 100644
--- a/tests/datasets/test_manager.py
+++ b/tests/datasets/test_manager.py
@@ -17,6 +17,7 @@
# under the License.
from __future__ import annotations
+import itertools
from unittest import mock
import pytest
@@ -38,11 +39,9 @@ def mock_task_instance():
def create_mock_dag():
- n = 1
- while True:
+ for dag_id in itertools.count(1):
mock_dag = mock.Mock()
- mock_dag.dag_id = n
- n += 1
+ mock_dag.dag_id = dag_id
yield mock_dag