o-nikolas commented on code in PR #54250:
URL: https://github.com/apache/airflow/pull/54250#discussion_r2267828432
##########
providers/amazon/src/airflow/providers/amazon/aws/triggers/base.py:
##########
@@ -140,9 +144,21 @@ def serialize(self) -> tuple[str, dict[str, Any]]:
def hook(self) -> AwsGenericHook:
"""Override in subclasses to return the right hook."""
- async def run(self) -> AsyncIterator[TriggerEvent]:
+ @asynccontextmanager
+ async def get_managed_client(self):
hook = self.hook()
- async with await hook.get_async_conn() as client:
+ key = hook.aws_conn_id
+
+ async with self._pool_lock:
+ if key not in self._client_pool:
+ self._client_pool[key] = await hook.get_async_conn()
+
+ yield self._client_pool[key]
+ # Can implement TTL logic here to clean-up stale clients
Review Comment:
Agreed, we'll need to handle session timeouts. We hit this in the AWS
executors that use persistent/long-lived connections. We have specific code to
detect when the connection is expired and repair it:
https://github.com/apache/airflow/blob/8ef0ac3e473efb0c36fdecae5fe5b73fbdc186d4/providers/amazon/src/airflow/providers/amazon/aws/executors/ecs/ecs_executor.py#L236-L253
We could do something similar here.
--
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]