ashb commented on a change in pull request #21301:
URL: https://github.com/apache/airflow/pull/21301#discussion_r806697988
##########
File path: airflow/jobs/scheduler_job.py
##########
@@ -48,7 +49,7 @@
from airflow.stats import Stats
from airflow.ti_deps.dependencies_states import EXECUTION_STATES
from airflow.utils import timezone
-from airflow.utils.callback_requests import DagCallbackRequest,
TaskCallbackRequest
+from airflow.utils.callback_requests import DagCallbackRequest,
SlaCallbackRequest, TaskCallbackRequest
Review comment:
Let's move this out of `airflow.utils` and in to `airflow.callbacks` as
utils is a huge messy dumping ground.
##########
File path: airflow/callbacks/pipe_callbacks_sink.py
##########
@@ -0,0 +1,47 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+from multiprocessing.connection import Connection as MultiprocessingConnection
+from typing import Callable
+
+from airflow.callbacks.base_callbacks_sink import BaseCallbacksSink
+from airflow.utils.callback_requests import CallbackRequest
+
+
+class PipeCallbacksSink(BaseCallbacksSink):
+ """
+ Class for sending callbacks to DagProcessor using pipe.
+
+ It is used when DagProcessor if not executed in standalone mode.
+ """
+
+ def __init__(self, get_sink_pipe: Callable[[], MultiprocessingConnection]):
+ self._get_sink_pipe = get_sink_pipe
+
+ def send_callback_to_execute(self, callback: CallbackRequest):
+ """
+ Sends information about the callback to be executed by Pipe.
+
+ :param callback: Callback request to be executed.
+ """
+ try:
+ self._get_sink_pipe().send(callback)
Review comment:
Why does this need to be a callable instead of just the value directly?
##########
File path: airflow/jobs/scheduler_job.py
##########
@@ -664,6 +665,10 @@ def _execute(self) -> None:
try:
self.executor.job_id = self.id
+ self.executor.callbacks_sink = PipeCallbacksSink(
Review comment:
```suggestion
self.executor.callback_sink = PipeCallbacksSink(
```
`callbacks_sink` looks slightly odd to me as an English speaker.
--
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]