amoghrajesh commented on code in PR #68232:
URL: https://github.com/apache/airflow/pull/68232#discussion_r3527274545


##########
task-sdk/src/airflow/sdk/execution_time/context.py:
##########
@@ -544,10 +565,19 @@ def get(self, key: str, default: JsonValue = None) -> 
JsonValue:
         ``datetime`` is not JSON-serializable; store it as 
``value.isoformat()`` and
         parse it back with ``datetime.fromisoformat(result)``.
         """
-        from airflow.sdk.execution_time.comms import ErrorResponse, 
GetTaskStateStore, TaskStateStoreResult
         from airflow.sdk.execution_time.task_runner import SUPERVISOR_COMMS
 
         resp = SUPERVISOR_COMMS.send(GetTaskStateStore(ti_id=self._ti_id, 
key=key))
+        return self._extract_get_response(resp, key, default)
+
+    async def aget(self, key: str, default: JsonValue = None) -> JsonValue:
+        """Async version of :meth:`get` that awaits instead of blocking the 
event loop."""
+        from airflow.sdk.execution_time.task_runner import SUPERVISOR_COMMS
+
+        resp = await 
SUPERVISOR_COMMS.asend(GetTaskStateStore(ti_id=self._ti_id, key=key))
+        return self._extract_get_response(resp, key, default)
+
+    def _extract_get_response(self, resp: Any, key: str, default: JsonValue) 
-> JsonValue:
 

Review Comment:
   ```suggestion
   ```



##########
task-sdk/src/airflow/sdk/execution_time/context.py:
##########
@@ -579,9 +609,19 @@ def set(self, key: str, value: JsonValue, *, retention: 
timedelta | None = None)
         - ``NEVER_EXPIRE`` — key never expires, regardless of the global 
config and is skipped by garbage collection.
         - ``None`` (default) — use the global ``[state_store] 
default_retention_days`` config.
         """
-        from airflow.sdk.execution_time.comms import SetTaskStateStore
         from airflow.sdk.execution_time.task_runner import SUPERVISOR_COMMS
 
+        SUPERVISOR_COMMS.send(self._build_set_message(key, value, retention))
+
+    async def aset(self, key: str, value: JsonValue, *, retention: timedelta | 
None = None) -> None:

Review Comment:
   `aget` and `aset` arent tested against a custom backend whose 
serialize_task_state_store_to_ref/deserialize_task_state_store_from_ref is 
overriden, can you please validate that and add a test maybe?



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

Reply via email to