You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/03/02 06:21:57 UTC

[GitHub] [airflow] ephraimbuddy commented on a change in pull request #21731: Store callbacks in database if standalone_dag_processor config is True.

ephraimbuddy commented on a change in pull request #21731:
URL: https://github.com/apache/airflow/pull/21731#discussion_r817380674



##########
File path: airflow/dag_processing/manager.py
##########
@@ -591,6 +594,27 @@ def _run_parsing_loop(self):
                 else:
                     poll_time = 0.0
 
+    @provide_session
+    def _fetch_callbacks(self, max_callbacks: int, session: Session = NEW_SESSION):
+        """Fetches callbacks from database and add them to the internal pipe for execution."""
+        if not conf.getboolean("scheduler", "standalone_dag_processor"):
+            # Nothing to do if callbacks are not stored in the database
+            return
+        self.log.debug("Fetching callbacks from the database.")
+        callbacks = (
+            session.query(DbCallbackRequest)
+            .order_by(DbCallbackRequest.priority_weight.asc())
+            .limit(max_callbacks)
+            .all()
+        )
+        for callback in callbacks:
+            try:
+                self._signal_conn.send(callback.get_callback_request())
+                session.delete(callback)
+            except Exception as e:
+                self.log.warning("Error adding callback for execution: %s, %s", callback, e)
+        session.commit()

Review comment:
       ```suggestion
   ```
   
   Do we need it? I think `provide_session` also commits the session




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org