kaxil commented on a change in pull request #9631:
URL: https://github.com/apache/airflow/pull/9631#discussion_r453239424
##########
File path: docs/concepts.rst
##########
@@ -269,6 +269,26 @@ a unique ``task_id`` for each generated operator.
Task ids are generated by appending a number at the end of the original task
id. For the above example, the DAG will have
the following task ids: ``[update_user, update_user__1, update_user__2, ...
update_user__n]``.
+Accessing current context
+-------------------------
+
+To retrieve current execution context you can use ``get_current_context``
method. In this way
+you can gain access to context dictionary from within your operators. This is
especially helpful when
+using ``@task`` decorator.
+
+.. code-block:: python
+
+ from airflow.decorators import task
+ from airflow.task.context import get_current_context
+
+ @task
+ def my_task():
+ context = get_current_context()
+ ti = context["ti"]
+
+Current context is accessible only during the tak execution. Calling this
method outside this context will
+rise an error.
Review comment:
```suggestion
raise an error.
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]