Skip to content

Commit 4e10c25

Browse files
authored
Rename processor_poll_interval to scheduler_idle_sleep_time (#18704)
`[scheduler] processor_poll_interval` setting in `airflow.cfg` has been renamed to `[scheduler] scheduler_idle_sleep_time` for better understanding.
1 parent 57bb47f commit 4e10c25

File tree

7 files changed

+45
-14
lines changed

7 files changed

+45
-14
lines changed

UPDATING.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,27 @@ with DAG(dag_id="task_concurrency_example"):
177177
BashOperator(task_id="t1", max_active_tis_per_dag=2, bash_command="echo Hi")
178178
```
179179
180+
### `processor_poll_interval` config have been renamed to `scheduler_idle_sleep_time`
181+
182+
`[scheduler] processor_poll_interval` setting in `airflow.cfg` has been renamed to `[scheduler] scheduler_idle_sleep_time`
183+
for better understanding.
184+
185+
It controls the 'time to sleep' at the end of the Scheduler loop if nothing was scheduled inside `SchedulerJob`.
186+
187+
**Before**:
188+
189+
```ini
190+
[scheduler]
191+
processor_poll_interval = 16
192+
```
193+
194+
**Now**:
195+
196+
```ini
197+
[scheduler]
198+
scheduler_idle_sleep_time = 16
199+
```
200+
180201
### Marking success/failed automatically clears failed downstream tasks
181202
182203
When marking a task success/failed in Graph View, its downstream tasks that are in failed/upstream_failed state are automatically cleared.

airflow/config_templates/config.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,13 +1739,12 @@
17391739
type: string
17401740
example: ~
17411741
default: "-1"
1742-
- name: processor_poll_interval
1742+
- name: scheduler_idle_sleep_time
17431743
description: |
17441744
Controls how long the scheduler will sleep between loops, but if there was nothing to do
17451745
in the loop. i.e. if it scheduled something then it will start the next loop
1746-
iteration straight away. This parameter is badly named (historical reasons) and it will be
1747-
renamed in the future with deprecation of the current name.
1748-
version_added: 1.10.6
1746+
iteration straight away.
1747+
version_added: 2.2.0
17491748
type: string
17501749
example: ~
17511750
default: "1"

airflow/config_templates/default_airflow.cfg

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -870,9 +870,8 @@ num_runs = -1
870870

871871
# Controls how long the scheduler will sleep between loops, but if there was nothing to do
872872
# in the loop. i.e. if it scheduled something then it will start the next loop
873-
# iteration straight away. This parameter is badly named (historical reasons) and it will be
874-
# renamed in the future with deprecation of the current name.
875-
processor_poll_interval = 1
873+
# iteration straight away.
874+
scheduler_idle_sleep_time = 1
876875

877876
# Number of seconds after which a DAG file is parsed. The DAG file is parsed every
878877
# ``min_file_process_interval`` number of seconds. Updates to DAGs are reflected after

airflow/configuration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ class AirflowConfigParser(ConfigParser):
167167
('metrics', 'statsd_datadog_tags'): ('scheduler', 'statsd_datadog_tags', '2.0.0'),
168168
('metrics', 'statsd_custom_client_path'): ('scheduler', 'statsd_custom_client_path', '2.0.0'),
169169
('scheduler', 'parsing_processes'): ('scheduler', 'max_threads', '1.10.14'),
170+
('scheduler', 'scheduler_idle_sleep_time'): ('scheduler', 'processor_poll_interval', '2.2.0'),
170171
('operators', 'default_queue'): ('celery', 'default_queue', '2.1.0'),
171172
('core', 'hide_sensitive_var_conn_fields'): ('admin', 'hide_sensitive_variable_fields', '2.1.0'),
172173
('core', 'sensitive_var_conn_names'): ('admin', 'sensitive_variable_fields', '2.1.0'),

airflow/jobs/scheduler_job.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import signal
2525
import sys
2626
import time
27+
import warnings
2728
from collections import defaultdict
2829
from datetime import timedelta
2930
from typing import Collection, DefaultDict, Dict, List, Optional, Tuple
@@ -86,9 +87,9 @@ class SchedulerJob(BaseJob):
8687
:param num_times_parse_dags: The number of times to try to parse each DAG file.
8788
-1 for unlimited times.
8889
:type num_times_parse_dags: int
89-
:param processor_poll_interval: The number of seconds to wait between
90+
:param scheduler_idle_sleep_time: The number of seconds to wait between
9091
polls of running processors
91-
:type processor_poll_interval: int
92+
:type scheduler_idle_sleep_time: int
9293
:param do_pickle: once a DAG object is obtained by executing the Python
9394
file, whether to serialize the DAG object to the DB
9495
:type do_pickle: bool
@@ -104,9 +105,10 @@ def __init__(
104105
subdir: str = settings.DAGS_FOLDER,
105106
num_runs: int = conf.getint('scheduler', 'num_runs'),
106107
num_times_parse_dags: int = -1,
107-
processor_poll_interval: float = conf.getfloat('scheduler', 'processor_poll_interval'),
108+
scheduler_idle_sleep_time: float = conf.getfloat('scheduler', 'scheduler_idle_sleep_time'),
108109
do_pickle: bool = False,
109110
log: logging.Logger = None,
111+
processor_poll_interval: Optional[float] = None,
110112
*args,
111113
**kwargs,
112114
):
@@ -117,7 +119,16 @@ def __init__(
117119
# number of times. This is only to support testing, and isn't something a user is likely to want to
118120
# configure -- they'll want num_runs
119121
self.num_times_parse_dags = num_times_parse_dags
120-
self._processor_poll_interval = processor_poll_interval
122+
if processor_poll_interval:
123+
# TODO: Remove in Airflow 3.0
124+
warnings.warn(
125+
"The 'processor_poll_interval' parameter is deprecated. "
126+
"Please use 'scheduler_idle_sleep_time'.",
127+
DeprecationWarning,
128+
stacklevel=2,
129+
)
130+
scheduler_idle_sleep_time = processor_poll_interval
131+
self._scheduler_idle_sleep_time = scheduler_idle_sleep_time
121132

122133
self.do_pickle = do_pickle
123134
super().__init__(*args, **kwargs)
@@ -676,7 +687,7 @@ def _run_scheduler_loop(self) -> None:
676687
# If the scheduler is doing things, don't sleep. This means when there is work to do, the
677688
# scheduler will run "as quick as possible", but when it's stopped, it can sleep, dropping CPU
678689
# usage when "idle"
679-
time.sleep(min(self._processor_poll_interval, next_event))
690+
time.sleep(min(self._scheduler_idle_sleep_time, next_event))
680691

681692
if loop_count >= self.num_runs > 0:
682693
self.log.info(

docs/apache-airflow/best-practices.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ In case you see long delays between updating it and the time it is ready to be t
314314
at the following configuration parameters and fine tune them according your needs (see details of
315315
each parameter by following the links):
316316

317-
* :ref:`config:scheduler__processor_poll_interval`
317+
* :ref:`config:scheduler__scheduler_idle_sleep_time`
318318
* :ref:`config:scheduler__min_file_process_interval`
319319
* :ref:`config:scheduler__dag_dir_list_interval`
320320
* :ref:`config:scheduler__parsing_processes`

docs/apache-airflow/concepts/scheduler.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ However you can also look at other non-performance-related scheduler configurati
366366
The scheduler can run multiple processes in parallel to parse DAG files. This defines
367367
how many processes will run.
368368

369-
- :ref:`config:scheduler__processor_poll_interval`
369+
- :ref:`config:scheduler__scheduler_idle_sleep_time`
370370
Controls how long the scheduler will sleep between loops, but if there was nothing to do
371371
in the loop. i.e. if it scheduled something then it will start the next loop
372372
iteration straight away. This parameter is badly named (historical reasons) and it will be

0 commit comments

Comments
 (0)