-
Notifications
You must be signed in to change notification settings - Fork 108
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
Protect the cache lock better #3604
Conversation
PBENCH-1317 We found a case where a cache lock could "leak" when an error occurs reading a file in the visualize and compare APIs. The file read has now been repackaged with a `finally` to be sure the stream is closed and unlocked on error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. (There's just a nit which we can ignore.)
datasets = params.query.get("datasets") | ||
benchmark_choice = None | ||
benchmark = None | ||
for dataset in datasets: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While initializing benchmark
here certainly doesn't hurt anything, I don't see how it helps anything, either: it is written unconditionally at line 113 before it is tested at line 116, so the initial value is always overwritten (and, benchmark
is never read if we don't enter the loop).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vscode
was unreasonably paranoid about the reference outside the loop, and I pre-declared the thing just to shut it up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious: I didn't see the reference outside the loop (otherwise, I probably would have ratified the paranoia). Still, I don't object to shutting up the linter (I think that's the better alternative to trying to ignore it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, here it is. Yeah, that reference probably should have been changed to benchmark_choice
, rather than expanding the scope of benchmark
....
PBENCH-1317
We found a case where a cache lock could "leak" when an error occurs reading a file in the visualize and compare APIs. The file read has now been repackaged with a
finally
to be sure the stream is closed and unlocked on error.