From e5eb607af8f12bb86d2b1c20103f764affa29fdd Mon Sep 17 00:00:00 2001 From: Brandon Truth Date: Fri, 24 May 2024 15:32:40 -0400 Subject: [PATCH 1/3] Update process_lock.py --- fasteners/process_lock.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fasteners/process_lock.py b/fasteners/process_lock.py index 1197731..292f1b7 100644 --- a/fasteners/process_lock.py +++ b/fasteners/process_lock.py @@ -26,6 +26,7 @@ from typing import Callable from typing import Optional from typing import Union +from s3fs import S3FileSystem from fasteners import _utils from fasteners.process_mechanism import _interprocess_mechanism @@ -79,6 +80,10 @@ def __init__(self, self.acquired = False self.sleep_func = sleep_func self.logger = _utils.pick_first_not_none(logger, LOG) + if self.path.startswith("s3://"): + self._open = _utils.s3_fs().open + else: + self._open = open def _try_acquire(self, blocking, watch): try: @@ -111,7 +116,7 @@ def _do_open(self): # the target file. This eliminates the possibility of an attacker # creating a symlink to an important file in our lock path. if self.lockfile is None or self.lockfile.closed: - self.lockfile = open(self.path, 'a') + self.lockfile = self._open(self.path, 'a') def acquire(self, blocking: bool = True, From 2b4ddf278c36222e777573ce6a238e26c9c7994a Mon Sep 17 00:00:00 2001 From: Brandon Truth Date: Fri, 24 May 2024 15:34:03 -0400 Subject: [PATCH 2/3] Update requirements-pkg.txt --- requirements-pkg.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-pkg.txt b/requirements-pkg.txt index e47b6e9..1b8c996 100644 --- a/requirements-pkg.txt +++ b/requirements-pkg.txt @@ -1,2 +1,3 @@ build twine +s3fs From 72808d9588a99a1f40843a93383fb0201904eb7a Mon Sep 17 00:00:00 2001 From: Brandon Truth Date: Fri, 24 May 2024 15:44:25 -0400 Subject: [PATCH 3/3] Update process_lock.py --- fasteners/process_lock.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fasteners/process_lock.py b/fasteners/process_lock.py index 292f1b7..99fe10b 100644 --- a/fasteners/process_lock.py +++ b/fasteners/process_lock.py @@ -81,7 +81,11 @@ def __init__(self, self.sleep_func = sleep_func self.logger = _utils.pick_first_not_none(logger, LOG) if self.path.startswith("s3://"): - self._open = _utils.s3_fs().open + self._open = S3FileSystem( + endpoint_url=os.environ["AWS_ENDPOINT_URL"], + key=os.environ["AWS_ACCESS_KEY_ID"], + secret=os.environ["AWS_SECRET_ACCESS_KEY"] + ).open else: self._open = open