ashb commented on a change in pull request #7269: [AIRFLOW-6651] Add Redis 
Heartbeat option
URL: https://github.com/apache/airflow/pull/7269#discussion_r383535134
 
 

 ##########
 File path: airflow/jobs/local_task_job.py
 ##########
 @@ -161,3 +166,55 @@ def heartbeat_callback(self, session=None):
                 ti.task.on_success_callback(context)
             self.task_runner.terminate()
             self.terminating = True
+
+    @classmethod
+    def get_zombie_running_tis(cls, limit_dttm, session=None):
+        def batch_get(acc, items):
+            # Redis has no batch functionality for zscore
+            # see https://github.com/antirez/redis/issues/2344
+            lua_script = '''
+                local res = {}
+                while #ARGV > 0 do
+                    res[#res+1] = redis.call('ZSCORE', KEYS[1], 
table.remove(ARGV, 1))
+                end
+                return res
+            '''
+            from airflow.jobs import LocalTaskJob
+            return acc + 
cls.redis.register_script(lua_script)(keys=[LocalTaskJob.__name__], args=items)
+
+        TI = airflow.models.TaskInstance
+
+        if conf.getboolean('heartbeat', 'redis_enabled'):
 
 Review comment:
   Get Boolean is a relatively expensive call, we should avoid calling this 
repeatedly

----------------------------------------------------------------
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