Taragolis commented on code in PR #39650:
URL: https://github.com/apache/airflow/pull/39650#discussion_r1602187132


##########
airflow/task/task_runner/standard_task_runner.py:
##########
@@ -186,3 +193,12 @@ def get_process_pid(self) -> int:
         if self.process is None:
             raise RuntimeError("Process is not started yet")
         return self.process.pid
+
+    def _read_task_utilization(self):
+        while True:
+            dag_id = self._task_instance.dag_id
+            task_id = self._task_instance.task_id
+            mem_usage = self.process.memory_percent()
+            cpu_usage = self.process.cpu_percent(interval=1)

Review Comment:
   And also we might want to handle `AttributeError` since `self.process` might 
be changed in MainThread
   
   
https://github.com/apache/airflow/blob/5de907504b151eb49e064bb21f5672c142bd595a/airflow/task/task_runner/standard_task_runner.py#L153-L154
   
   
https://github.com/apache/airflow/blob/5de907504b151eb49e064bb21f5672c142bd595a/airflow/task/task_runner/standard_task_runner.py#L170-L172
   
   Otherwise daemon could be terminated due to exception and it will be written 
write it into the logs, which might confuse users



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

Reply via email to