Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Worker] Fix potential issue that can appear during func_obj loading from cache #1341

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
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
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
-

### Changed
-
- [Setup] Removed unused 'lxml', 'docker' and 'python-dateutil' packages from the setup.py
- [Core] Detached progress bar from INFO logs
- [Localhost] Upgraded localhost backend v2
- [Future] Expose 'wait_dur_sec' and 'retries' in future.wait() and future.get_result() methods

### Fixed
-
- [AWS Lambda] Fixed wrong AWS Lambda delete runtime_name match semantics
- [Worker] Fixed potential issue that can appear during 'func_obj' loading from cache
- [Monitor] Prevent potential 'keyerror' exception


## [v3.3.0]
Expand Down
11 changes: 8 additions & 3 deletions lithops/worker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def get_function_and_modules(job, internal_storage):
logger.info("Getting function and modules")
backend = job.config['lithops']['backend']
func_path = '/'.join([LITHOPS_TEMP_DIR, job.func_key])
func_obj = None

if job.config[backend].get('runtime_include_function'):
logger.info("Runtime include function feature activated. Loading "
Expand All @@ -59,9 +60,13 @@ def get_function_and_modules(job, internal_storage):
func_obj = f.read()
elif os.path.exists(func_path):
logger.info(f"Loading {job.func_key} from local cache")
with open(func_path, 'rb') as f:
func_obj = f.read()
else:
try:
with open(func_path, 'rb') as f:
func_obj = f.read()
except Exception:
logger.debug(f"Could not load {job.func_key} from local cache")

if not func_obj:
logger.info(f"Loading {job.func_key} from storage")
func_obj = internal_storage.get_func(job.func_key)
os.makedirs(os.path.dirname(func_path), exist_ok=True)
Expand Down
Loading