jscheffl commented on code in PR #65943:
URL: https://github.com/apache/airflow/pull/65943#discussion_r3236890588


##########
providers/edge3/src/airflow/providers/edge3/cli/worker.py:
##########
@@ -603,37 +678,32 @@ async def fetch_and_run_job(self) -> None:
             self.background_tasks.add(task)
             task.add_done_callback(self.background_tasks.discard)
 
-        while job.is_running and results_queue.empty():
+        while job.should_poll_logs:
             await self._push_logs_in_chunks(job)
             for _ in range(0, self.job_poll_interval * 10):
                 await sleep(0.1)
                 if not job.is_running:
                     break
         await self._push_logs_in_chunks(job)
-        supervisor_msg = (
-            "(Unknown error, no exception details available)"
-            if results_queue.empty()
-            else results_queue.get()
-        )
-        # Ensure that supervisor really ended after we grabbed results from 
queue
-        while True:
-            if not job.is_running:
-                break
+        # Wait for the child process to fully exit.
+        while job.is_running:  # noqa: ASYNC110
             await sleep(0.1)
 
         self.jobs.remove(job)
         if job.is_success:
             logger.info("Job completed: %s", job.edge_job.identifier)
             await jobs_set_state(job.edge_job.key, TaskInstanceState.SUCCESS)
+            job.cleanup()
         else:
-            if isinstance(supervisor_msg, Exception):
-                supervisor_msg = 
"\n".join(traceback.format_exception(supervisor_msg))
-            logger.error("Job failed: %s with:\n%s", job.edge_job.identifier, 
supervisor_msg)
+            ex_txt = job.failure_details()
+            job.cleanup()

Review Comment:
   Nit: could save 1 LoC by moving `job-cleanup()`behind `await 
jobs_set_state()`



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