ramitkataria commented on code in PR #53831:
URL: https://github.com/apache/airflow/pull/53831#discussion_r2283664747
##########
airflow-core/src/airflow/triggers/deadline.py:
##########
@@ -49,7 +49,21 @@ async def run(self) -> AsyncIterator[TriggerEvent]:
try:
callback = import_string(self.callback_path)
- result = await callback(**self.callback_kwargs)
+
+ # TODO: get airflow context
+ context: dict = {}
+
+ # If callback is an awaitable class, callback_kwargs will be used
as parameters to the constructor
+ if hasattr(callback, "__await__"):
+ callback_instance = callback(**self.callback_kwargs)
+
+ # Since parameters cannot be passed in __await__, context is
passed as an attribute
+ callback_instance.context = context
Review Comment:
Earlier, I did it that way to keep the constructor consistent across async
and sync usage but I just realized that this code can be made simpler if I just
pass it in the constructor so I've now added it as an optional parameter to the
`BaseNotifier`.
Notifiers are also the major examples of what these callback classes would
look like in almost all cases but technically, it is possible to use any class
that implements `__await__` and has a constructor that accepts context
--
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]