Programmer-RD-AI commented on code in PR #54250:
URL: https://github.com/apache/airflow/pull/54250#discussion_r2261824757
##########
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:
as far as I checked there is no specific need for a TTL, since there are no
issues from boto's side of things, the only edge case that could come up is
that their AWS Session Token could expire (which we use for the specific
client) and it could lead to some issue, but i think generally allowing the
user to customize the ttl should be a nice to have IMO.
--
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]