potiuk commented on code in PR #33227:
URL: https://github.com/apache/airflow/pull/33227#discussion_r1295590748


##########
airflow/providers/apache/beam/triggers/beam.py:
##########
@@ -85,31 +85,30 @@ def serialize(self) -> tuple[str, dict[str, Any]]:
     async def run(self) -> AsyncIterator[TriggerEvent]:  # type: 
ignore[override]
         """Get current pipeline status and yields a TriggerEvent."""
         hook = self._get_async_hook()
-        while True:
-            try:
-                return_code = await hook.start_python_pipeline_async(
-                    variables=self.variables,
-                    py_file=self.py_file,
-                    py_options=self.py_options,
-                    py_interpreter=self.py_interpreter,
-                    py_requirements=self.py_requirements,
-                    py_system_site_packages=self.py_system_site_packages,
+        try:
+            return_code = await hook.start_python_pipeline_async(
+                variables=self.variables,
+                py_file=self.py_file,
+                py_options=self.py_options,
+                py_interpreter=self.py_interpreter,
+                py_requirements=self.py_requirements,
+                py_system_site_packages=self.py_system_site_packages,
+            )
+        except Exception as e:
+            self.log.exception("Exception occurred while checking for pipeline 
state")
+            yield TriggerEvent({"status": "error", "message": str(e)})
+            return
+        else:

Review Comment:
   Nice. I really started to like using else on try/except :)



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