jscheffl commented on code in PR #45958:
URL: https://github.com/apache/airflow/pull/45958#discussion_r1936223926
##########
providers/edge/src/airflow/providers/edge/cli/edge_command.py:
##########
@@ -302,14 +304,19 @@ def start(self):
def loop(self):
"""Run a loop of scheduling and monitoring tasks."""
new_job = False
+ previous_jobs = self.jobs
if not any((_EdgeWorkerCli.drain, _EdgeWorkerCli.maintenance_mode))
and self.free_concurrency > 0:
new_job = self.fetch_job()
self.check_running_jobs()
- if _EdgeWorkerCli.drain or datetime.now().timestamp() -
self.last_hb.timestamp() > self.hb_interval:
- worker_state_changed = self.heartbeat()
- # If worker state changed, send heartbeat immdediately.
- self.last_hb = datetime.now() if not worker_state_changed else
self.last_hb
+ if (
+ _EdgeWorkerCli.drain
+ or datetime.now().timestamp() - self.last_hb.timestamp() >
self.hb_interval
+ or self.worker_state_changed # send heartbeat immediately if the
state is different in db
+ or bool(previous_jobs) != bool(self.jobs) # when number of jobs
changes from/to 0
Review Comment:
Cool!
--
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]