ramitkataria commented on code in PR #53201:
URL: https://github.com/apache/airflow/pull/53201#discussion_r2201559598
##########
airflow-core/src/airflow/models/deadline.py:
##########
@@ -98,6 +107,33 @@ def _determine_resource() -> tuple[str, str]:
f"{self.deadline_time} or run: {self.callback}({callback_kwargs})"
)
+ def handle_miss(self, session: Session):
+ """Handle a missed deadline by creating and starting a trigger to run
the callback."""
+ callback_func = import_string(self.callback)
+ if not asyncio.iscoroutinefunction(callback_func):
+ # TODO: For sync callbacks, use executor instead of trigger
+ logger.error("Sync callbacks not supported yet: %s", self.callback)
+ return
+
+ callback_trigger = DeadlineCallbackTrigger(
+ callback_func=self.callback,
+ callback_kwargs=self.callback_kwargs or {},
+ )
+
+ trigger_orm = Trigger.from_object(callback_trigger)
+ session.add(trigger_orm)
+ session.flush()
Review Comment:
That's what I tried earlier but I think this flush is needed before the
second add because the trigger's id wouldn't exist before the flush. Also,
there's another flush/commit called somewhere along the call stack after the
second add so it doesn't need the explicit flush here
--
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]