ashb commented on code in PR #68232:
URL: https://github.com/apache/airflow/pull/68232#discussion_r3465160485
##########
task-sdk/src/airflow/sdk/execution_time/context.py:
##########
@@ -628,6 +653,16 @@ def delete(self, key: str) -> None:
if backend is not None:
backend.delete(self._scope, key)
+ async def adelete(self, key: str) -> None:
+ """Async version of :meth:`delete` that awaits instead of blocking the
event loop."""
+ from airflow.sdk.execution_time.comms import DeleteTaskStateStore
Review Comment:
Ditto.
I think SUPERVISOR_COMMS is the only thing that should be imported at
function scope
##########
task-sdk/src/airflow/sdk/execution_time/context.py:
##########
@@ -571,9 +584,21 @@ 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:
+ """Async version of :meth:`set` that awaits instead of blocking the
event loop."""
+ from airflow.sdk.execution_time.task_runner import SUPERVISOR_COMMS
+
+ await SUPERVISOR_COMMS.asend(self._build_set_message(key, value,
retention))
+
+ def _build_set_message(
+ self, key: str, value: JsonValue, retention: timedelta | None
+ ) -> SetTaskStateStore:
+ from airflow.sdk.execution_time.comms import SetTaskStateStore
Review Comment:
This import should be at the module level
--
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]