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

Fix access_threaded in the forthcoming interactive threadpool world #972

Merged
merged 1 commit into from
Nov 30, 2022

Conversation

quinnj
Copy link
Member

@quinnj quinnj commented Nov 30, 2022

Fixes #970.

The issue here is that our access_threaded function, and thread-specific arrays, all relied on Threads.nthreads(), which by default only returns the number of threads in the :default threadpool. In the new world where the :interactive threadpool exists, there can also be threads there.

There is a new function Threads.maxthreadid() which helpfully tells us the max id of any thread, regardless of threadpool. So the proposed fix here is that if that function is defined, use that, otherwise fallback to Threads.nthreads().

Fixes #970.

The issue here is that our `access_threaded` function, and thread-specific
arrays, all relied on `Threads.nthreads()`, which by default only returns
the number of threads in the `:default` threadpool. In the new world where
the `:interactive` threadpool exists, there can also be threads there.

There is a new function `Threads.maxthreadid()` which helpfully tells us
the max id of any thread, regardless of threadpool. So the proposed fix
here is that if that function is defined, use that, otherwise fallback
to `Threads.nthreads()`.
@quinnj
Copy link
Member Author

quinnj commented Nov 30, 2022

cc: @KristofferC, since, if I remember correctly, he was the original author of this utility? Just as an FYI in case other packages will also need this change in the future (like Parsers.jl).

@codecov-commenter
Copy link

Codecov Report

Merging #972 (b321b8c) into master (9a95100) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #972      +/-   ##
==========================================
- Coverage   79.99%   79.97%   -0.03%     
==========================================
  Files          36       36              
  Lines        2959     2961       +2     
==========================================
+ Hits         2367     2368       +1     
- Misses        592      593       +1     
Impacted Files Coverage Δ
src/Parsers.jl 97.29% <100.00%> (+0.02%) ⬆️
src/Servers.jl 79.47% <100.00%> (ø)
src/parsemultipart.jl 91.30% <100.00%> (+0.07%) ⬆️
src/WebSockets.jl 87.45% <0.00%> (-0.37%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@quinnj quinnj merged commit 16383f2 into master Nov 30, 2022
@quinnj quinnj deleted the jq-fix-access-threaded branch November 30, 2022 15:06
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.

serve() fails when run from an :interactive thread (Julia >=1.9)
3 participants