You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "hussein-awala (via GitHub)" <gi...@apache.org> on 2023/08/06 22:42:02 UTC

[GitHub] [airflow] hussein-awala commented on a diff in pull request #32990: Timeout Airflow TI and Sensors when using defferable mode

hussein-awala commented on code in PR #32990:
URL: https://github.com/apache/airflow/pull/32990#discussion_r1285271196


##########
airflow/models/taskinstance.py:
##########
@@ -166,6 +166,16 @@ class TaskReturnCode(Enum):
     """When task exits with deferral to trigger."""
 
 
+def get_current_context() -> Context:
+    """Retrieve the execution context dictionary without altering user method's signature."""
+    if not _CURRENT_CONTEXT:
+        raise AirflowException(
+            "Current context was requested but no context was found! "
+            "Are you running within an airflow task?"
+        )
+    return _CURRENT_CONTEXT[-1]

Review Comment:
   Currently I duplicated it, but I think we should move it to TI (or base operator class), since it is useful in all the operators and not just in Python operators. WDYT?



-- 
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