-
Notifications
You must be signed in to change notification settings - Fork 5
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
make _CACHE thread-safe #123
Conversation
Codecov Report
@@ Coverage Diff @@
## master #123 +/- ##
==========================================
+ Coverage 96.87% 97.71% +0.84%
==========================================
Files 6 6
Lines 224 219 -5
==========================================
- Hits 217 214 -3
+ Misses 7 5 -2
Continue to review full report at Codecov.
|
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.
LGTM, though I think a failing multi-threaded test would be a good idea...
global _CACHE[:PKGS][pkg] = ver | ||
lock(_CACHE_LOCK) do | ||
if isempty(_CACHE[:PKGS]) | ||
for (pkg, ver) in Pkg.installed() |
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.
Hmm, I think we should have a failing test cases that's fixed by this change? I wonder if we should mock the Pkg.installed()
call in order to write an initially failing test for the non-threadsafe version? @oxinabox Do you have any opinions/suggestions on this?
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.
I agree a test would nice. But I'm not sure how to write one in this case.
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.
I can't think how to do this reliably.
Because the scheduler never promises to run things concurrently
Race conditions are basically impossible to unit test. So I do not think this is required. |
Bump :) |
Thanks! |
The global variable
_CACHE
is not thread-safe. This PR should fix that.