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/03 23:42:42 UTC
[airflow] branch main updated: Refactor unneeded 'continue' jumps in cli (#33845)
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 05a0542b5a Refactor unneeded 'continue' jumps in cli (#33845)
05a0542b5a is described below
commit 05a0542b5ab1ec0f6eb86fa545bba524ad8db9f3
Author: Miroslav Šedivý <67...@users.noreply.github.com>
AuthorDate: Sun Sep 3 23:42:35 2023 +0000
Refactor unneeded 'continue' jumps in cli (#33845)
---
airflow/cli/cli_config.py | 8 ++------
airflow/cli/commands/internal_api_command.py | 5 ++---
airflow/cli/commands/kubernetes_command.py | 4 ++--
airflow/cli/commands/webserver_command.py | 5 ++---
4 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/airflow/cli/cli_config.py b/airflow/cli/cli_config.py
index e8e096ee6f..01dbe7080c 100644
--- a/airflow/cli/cli_config.py
+++ b/airflow/cli/cli_config.py
@@ -92,12 +92,8 @@ class Arg:
self.flags = flags
self.kwargs = {}
for k, v in locals().items():
- if v is _UNSET:
- continue
- if k in ("self", "flags"):
- continue
-
- self.kwargs[k] = v
+ if k not in ("self", "flags") and v is not _UNSET:
+ self.kwargs[k] = v
def add_to_parser(self, parser: argparse.ArgumentParser):
"""Add this argument to an ArgumentParser."""
diff --git a/airflow/cli/commands/internal_api_command.py b/airflow/cli/commands/internal_api_command.py
index b9b77c0934..7b2cf798da 100644
--- a/airflow/cli/commands/internal_api_command.py
+++ b/airflow/cli/commands/internal_api_command.py
@@ -187,11 +187,10 @@ def internal_api(args):
# Reading pid of gunicorn main process as it will be different that
# the one of process spawned above.
- while True:
+ gunicorn_master_proc_pid = None
+ while not gunicorn_master_proc_pid:
sleep(0.1)
gunicorn_master_proc_pid = read_pid_from_pidfile(pid_file)
- if gunicorn_master_proc_pid:
- break
# Run Gunicorn monitor
gunicorn_master_proc = psutil.Process(gunicorn_master_proc_pid)
diff --git a/airflow/cli/commands/kubernetes_command.py b/airflow/cli/commands/kubernetes_command.py
index 038f53e3f3..2d9a488ebb 100644
--- a/airflow/cli/commands/kubernetes_command.py
+++ b/airflow/cli/commands/kubernetes_command.py
@@ -142,8 +142,8 @@ def cleanup_pods(args):
_delete_pod(pod.metadata.name, namespace)
except ApiException as e:
print(f"Can't remove POD: {e}", file=sys.stderr)
- continue
- print(f"No action taken on pod {pod_name}")
+ else:
+ print(f"No action taken on pod {pod_name}")
continue_token = pod_list.metadata._continue
if not continue_token:
break
diff --git a/airflow/cli/commands/webserver_command.py b/airflow/cli/commands/webserver_command.py
index d0b246eed0..79694db59d 100644
--- a/airflow/cli/commands/webserver_command.py
+++ b/airflow/cli/commands/webserver_command.py
@@ -493,11 +493,10 @@ def webserver(args):
# Reading pid of gunicorn master as it will be different that
# the one of process spawned above.
- while True:
+ gunicorn_master_proc_pid = None
+ while not gunicorn_master_proc_pid:
sleep(0.1)
gunicorn_master_proc_pid = read_pid_from_pidfile(pid_file)
- if gunicorn_master_proc_pid:
- break
# Run Gunicorn monitor
gunicorn_master_proc = psutil.Process(gunicorn_master_proc_pid)