feluelle commented on a change in pull request #5127: [AIRFLOW-4343] Show 
warning in UI if scheduler is not running
URL: https://github.com/apache/airflow/pull/5127#discussion_r276793341
 
 

 ##########
 File path: airflow/jobs.py
 ##########
 @@ -98,25 +98,48 @@ class BaseJob(Base, LoggingMixin):
         Index('idx_job_state_heartbeat', state, latest_heartbeat),
     )
 
+    heartrate = conf.getfloat('scheduler', 'JOB_HEARTBEAT_SEC'),
+
     def __init__(
             self,
             executor=executors.get_default_executor(),
-            heartrate=conf.getfloat('scheduler', 'JOB_HEARTBEAT_SEC'),
+            heartrate=None,
             *args, **kwargs):
         self.hostname = get_hostname()
         self.executor = executor
         self.executor_class = executor.__class__.__name__
         self.start_date = timezone.utcnow()
         self.latest_heartbeat = timezone.utcnow()
-        self.heartrate = heartrate
+        if heartrate is not None:
+            self.heartrate = heartrate
         self.unixname = getpass.getuser()
         self.max_tis_per_query = conf.getint('scheduler', 'max_tis_per_query')
         super(BaseJob, self).__init__(*args, **kwargs)
 
-    def is_alive(self):
+    @classmethod
+    @provide_session
+    def most_recent_job(cls, session):  # type: (Session) -> Optional[BaseJob]
+        """
+        Return the most recent job of this type, if any, based on last
+        heartbeat received.
+
+        This method should be called on a subclass (i.e. on SchedulerJob) to
+        return jobs of that type.
+
 
 Review comment:
   Do you mind adding a short description of the `session` arg?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to