Skip to content

Commit 898f332

Browse files
potiuk0vj00
authored andcommitted
Fix broken stat scheduler_loop_duration (#42886) (#43544)
* wip * wip * fix lint err --------- Co-authored-by: venkat <[email protected]> (cherry picked from commit 60b8056) Co-authored-by: Venkat VJ <[email protected]> (cherry picked from commit 842c60a)
1 parent 7aea4b5 commit 898f332

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

airflow/jobs/scheduler_job_runner.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,16 +1105,18 @@ def _run_scheduler_loop(self) -> None:
11051105
)
11061106

11071107
for loop_count in itertools.count(start=1):
1108-
with Trace.start_span(span_name="scheduler_job_loop", component="SchedulerJobRunner") as span:
1108+
with Trace.start_span(
1109+
span_name="scheduler_job_loop", component="SchedulerJobRunner"
1110+
) as span, Stats.timer("scheduler.scheduler_loop_duration") as timer:
11091111
span.set_attribute("category", "scheduler")
11101112
span.set_attribute("loop_count", loop_count)
1111-
with Stats.timer("scheduler.scheduler_loop_duration") as timer:
1112-
if self.using_sqlite and self.processor_agent:
1113-
self.processor_agent.run_single_parsing_loop()
1114-
# For the sqlite case w/ 1 thread, wait until the processor
1115-
# is finished to avoid concurrent access to the DB.
1116-
self.log.debug("Waiting for processors to finish since we're using sqlite")
1117-
self.processor_agent.wait_until_finished()
1113+
1114+
if self.using_sqlite and self.processor_agent:
1115+
self.processor_agent.run_single_parsing_loop()
1116+
# For the sqlite case w/ 1 thread, wait until the processor
1117+
# is finished to avoid concurrent access to the DB.
1118+
self.log.debug("Waiting for processors to finish since we're using sqlite")
1119+
self.processor_agent.wait_until_finished()
11181120

11191121
with create_session() as session:
11201122
# This will schedule for as many executors as possible.

0 commit comments

Comments
 (0)