Skip to content

Commit

Permalink
Prevent _s3_client from being serialized (#847)
Browse files Browse the repository at this point in the history
Co-authored-by: Saaketh Narayan <[email protected]>
Co-authored-by: Saaketh Narayan <[email protected]>
  • Loading branch information
3 people authored Dec 9, 2024
1 parent e1e28f1 commit 69304c5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions streaming/base/storage/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,15 @@ def _create_s3_client(self, unsigned: bool = False, timeout: float = DEFAULT_TIM
config=config,
endpoint_url=os.environ.get('S3_ENDPOINT_URL'))

def __getstate__(self) -> dict:
state = self.__dict__.copy()
state['_s3_client'] = None # Exclude _s3_client from being pickled
return state

def __setstate__(self, state: dict):
self.__dict__.update(state)
self._s3_client = None # Ensure _s3_client is reset after unpickling


class SFTPDownloader(CloudDownloader):
"""Download files from SFTP to local filesystem."""
Expand Down

0 comments on commit 69304c5

Please sign in to comment.