Skip to content

fix: EnvHelper unusable if error occurs during initialisation #954

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

Merged
merged 1 commit into from
May 21, 2024

Conversation

cecheta
Copy link
Collaborator

@cecheta cecheta commented May 20, 2024

Purpose

  • If an error occurs during env helper initialisation, the helper remains in a non-working state until the app restarts. This PR fixes this, so the env helper is only saved if it is created without any errors

Does this introduce a breaking change?

  • Yes
  • No

Copy link

Coverage

Coverage Report •
FileStmtsMissCoverMissing
code/backend/batch/utilities/helpers
   env_helper.py1351092%223, 228–229, 232–234, 246, 250–252
TOTAL242867272% 

Tests Skipped Failures Errors Time
206 0 💤 0 ❌ 0 🔥 12.606s ⏱️

@ross-p-smith
Copy link
Collaborator

Not for this PR - but wonder whether the @functools.cache would be simpler than the lock

@cecheta
Copy link
Collaborator Author

cecheta commented May 21, 2024

Not for this PR - but wonder whether the @functools.cache would be simpler than the lock

From what I quickly saw online, there could be multiple threads trying to create EnvHelpers at the same time during startup unless we use a lock

I don't think that would break the application, but I guess it wouldn't be a true singleton

@cecheta cecheta added this pull request to the merge queue May 21, 2024
Merged via the queue into main with commit 290fb05 May 21, 2024
9 checks passed
@cecheta cecheta deleted the cecheta/env-helper-error branch May 21, 2024 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants