Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/backend/base/langflow/services/storage/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ def __init__(self, session_service: SessionService, settings_service: SettingsSe
raise ImportError(msg) from exc

# Create session - AWS credentials are picked up from environment variables
self._aioboto3 = aioboto3
self.session = aioboto3.Session()
self._client = None
self._client = None # Persisted for quick reuse

self.set_ready()
logger.info(
Expand Down Expand Up @@ -87,7 +88,10 @@ def resolve_component_path(self, logical_path: str) -> str:

def _get_client(self):
"""Get or create an S3 client using the async context manager."""
return self.session.client("s3")
if self._client is None:
# Only create the client once and cache it for future calls.
self._client = self.session.client("s3")
return self._client

async def save_file(self, flow_id: str, file_name: str, data: bytes) -> None:
"""Save a file to S3.
Expand Down
Loading