cruseakshay commented on code in PR #60650:
URL: https://github.com/apache/airflow/pull/60650#discussion_r2706680933
##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/triggers/data_factory.py:
##########
@@ -74,39 +74,40 @@ async def run(self) -> AsyncIterator[TriggerEvent]:
hook =
AzureDataFactoryAsyncHook(azure_data_factory_conn_id=self.azure_data_factory_conn_id)
executed_after_token_refresh = False
try:
- while True:
- try:
- pipeline_status = await hook.get_adf_pipeline_run_status(
- run_id=self.run_id,
- resource_group_name=self.resource_group_name,
- factory_name=self.factory_name,
- )
- executed_after_token_refresh = False
- if pipeline_status ==
AzureDataFactoryPipelineRunStatus.FAILED:
- yield TriggerEvent(
- {"status": "error", "message": f"Pipeline run
{self.run_id} has Failed."}
+ async with hook:
+ while True:
+ try:
+ pipeline_status = await
hook.get_adf_pipeline_run_status(
+ run_id=self.run_id,
+ resource_group_name=self.resource_group_name,
+ factory_name=self.factory_name,
)
- return
- elif pipeline_status ==
AzureDataFactoryPipelineRunStatus.CANCELLED:
- msg = f"Pipeline run {self.run_id} has been Cancelled."
- yield TriggerEvent({"status": "error", "message": msg})
- return
- elif pipeline_status ==
AzureDataFactoryPipelineRunStatus.SUCCEEDED:
- msg = f"Pipeline run {self.run_id} has been Succeeded."
- yield TriggerEvent({"status": "success", "message":
msg})
- return
- await asyncio.sleep(self.poke_interval)
- except ServiceRequestError:
- # conn might expire during long running pipeline.
- # If exception is caught, it tries to refresh connection
once.
- # If it still doesn't fix the issue,
- # than the execute_after_token_refresh would still be False
- # and an exception will be raised
- if executed_after_token_refresh:
- await hook.refresh_conn()
executed_after_token_refresh = False
- else:
- raise
+ if pipeline_status ==
AzureDataFactoryPipelineRunStatus.FAILED:
Review Comment:
added _build_trigger_event
--
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]