-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add Lockable
to Base, to bundle a lock with its resource
#52898
Conversation
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.
SGTM
ArgTools tests are failing here, should be fixed by JuliaIO/ArgTools.jl#35. Alternatively, we could remove the |
Would probably be best not to hold up this PR for that change, but is almost done now, so can just see about rebasing onto soon: #53124 |
Co-authored-by: Jacob Quinn <[email protected]>
Co-authored-by: Dilum Aluthge <[email protected]>
Co-authored-by: Jameson Nash <[email protected]>
Test failed related:
|
Urg, I regret making the temp file changes here, I just wanted to show |
This reverts commit cf87d6a.
Failure seems unrelated now: cmdlineargs (7) | failed at 2024-02-04T00:12:08.906
Test Failed at /cache/build/tester-amdci4-12/julialang/julia-master/julia-8a35ded8ae/share/julia/test/cmdlineargs.jl:1065
Expression: success(pipeline(setenv(`$(Base.julia_cmd()) --bug-report=rr-local -e 'exit()'`, "JULIA_RR_RECORD_ARGS" => "-n --nested=ignore", "_RR_TRACE_DIR" => temp_trace_dir); )) |
Seems odd it would fail repeatedly though, when that test hasn't usually been a problem |
Indeed it is related. Running locally gives:
|
Sounds like HTTP.jl has a |
Or |
would be cool to have this in 1.11 if possible |
I don't have the ability to make a new JuliaServices/ConcurrentUtilities.jl#31 release, but once that is done, this should be able to merge |
You know what though, we don't actually have to wait for that. We will put off doing the actual export for a later day though. |
submitted a new ConcurrentUtilities.jl release |
Thanks! We will still merge this today, and then now can merge the export in a couple days or weeks to give people time to update to the new release |
Thanks for getting this in @vtjnash! |
redo of #34400
closes #52897
I think this can be useful, so putting it back up. (First commit I copied from https://github.com/JuliaServices/ConcurrentUtilities.jl/blob/main/src/lockable.jl, so I added @quinnj as a co-author, then I realized it came from #34400, so I added @DilumAluthge).
I am not sure about the
lock(f, ::Lockable)
method: it is nice because it unpacks the value for you, but it is weird because it unpacks the value for you. For aLockable
,f
must accept one argument, whereas for aLock
,f
must be 0-arg. ALockable
is not<:AbstractLock
here, so maybe this is allowed, but if we deleted thislock
method, we could inherit fromAbstractLock
and just use the generic one (requiring folks to unpack the value within the locked region themselves, as is the case for@lock
). I think it is preferred these days to use@lock
anyway, so having thelock(f,::Lockable)
method may be of limited value anyway.I searched Base and came up with two places that could currently use this internally,
TEMP_CLEANUP
andenv_dict
, so I've added commits to show the usage there.