-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Channels throw exception when filled and read from tasks on different threads (sticky = false
)
#32575
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
Comments
EDIT: Removed the rest of this post. I didn't realize that Atom was setting Here is a reproduction at the terminal: julia> versioninfo()
Julia Version 1.3.0-DEV.540
Commit faefe2ae64* (2019-07-13 08:34 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin18.6.0)
CPU: Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
Environment:
JULIA_NUM_THREADS = 4
julia> begin
ch = Channel{Char}(0)
t = Task(()->for v in "hello" put!(ch, v) end)
t.sticky = false
bind(ch, t)
schedule(t)
String(collect(ch)) == "hello"
end
ERROR: cannot switch to task running on another thread
Stacktrace:
[1] check_channel_state at ./channels.jl:117 [inlined]
[2] take_unbuffered(::Channel{Char}) at ./channels.jl:366
[3] take! at ./channels.jl:344 [inlined]
[4] iterate(::Channel{Char}, ::Nothing) at ./channels.jl:410
[5] _collect(::UnitRange{Int64}, ::Channel{Char}, ::Base.HasEltype, ::Base.SizeUnknown) at ./array.jl:570
[6] collect(::Channel{Char}) at ./array.jl:558
[7] top-level scope at REPL[2]:7 |
Thanks Jeff!! 😊👍 |
I'm opening this PR after some conversation on Slack about using
Channel
s with the new PART multithreaded task runtime. Sorry it took me so long to open this, @JeffBezanson.The Channel functions sometimes throw an exception when reading values off a channel:
cannot switch to task running on another thread
(I read #30186, which looks like it should have added multithreading support for Channels. So it's also possible that I'm actually just not using them correctly?)
Here is an example that seems to (sometimes) trigger the exception:
That seems to fail about 1/5 times I run it.
The text was updated successfully, but these errors were encountered: