JuliaSIMD / JuliaSIMD/Polyester.jl

Interrupting Julia disables `@batch` for this session

Open
#30 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
285
Forks
20
PR merge metrics
No merged PRs in 30d

Description

MWE:
```julia
using Polyester

function foo()
@batch for i in 1:4
println(Threads.threadid())
sleep(1)
end
end
```
When running this in a new REPL (Julia started with two threads, `julia -t 2`), the output of `foo()` is, as expected:
```julia-repl
julia> foo2()
1
2
1
2
```
I get the same output when running this multiple times.
Now, when I interrupt Julia before the function is done (that's what the `sleep` is for), `@batch` only uses one thread until I restart Julia:
```julia-repl
julia> foo2()
1
2
ERROR: InterruptException:
Stacktrace:
[1] poptask(W::Base.InvasiveLinkedListSynchronized{Task})
@ Base .\task.jl:760
[2] wait
@ .\task.jl:768 [inlined]
[3] wait(c::Base.GenericCondition{Base.Threads.SpinLock})
@ Base .\condition.jl:106
[4] _trywait(t::Timer)
@ Base .\asyncevent.jl:111
[5] wait
@ .\asyncevent.jl:129 [inlined]
[6] sleep(sec::Int64)
@ Base .\asyncevent.jl:214
[7] macro expansion
@ C:\Users\Erik\git\Trixi.jl\foo.jl:18 [inlined]
[8] #7
@ C:\Users\Erik\.julia\packages\Polyester\0DPCU\src\closure.jl:168 [inlined]
[9] macro expansion
@ C:\Users\Erik\.julia\packages\Polyester\0DPCU\src\batch.jl:79 [inlined]
[10] _batch_no_reserve
@ C:\Users\Erik\.julia\packages\Polyester\0DPCU\src\batch.jl:53 [inlined]
[11] batch
@ C:\Users\Erik\.julia\packages\Polyester\0DPCU\src\batch.jl:195 [inlined]
[12] macro expansion
@ C:\Users\Erik\.julia\packages\Polyester\0DPCU\src\closure.jl:164 [inlined]
[13] foo2()
@ Main C:\Users\Erik\git\Trixi.jl\foo.jl:16
[14] top-level scope
@ REPL[2]:1

julia> 2
julia> foo2()
1
1
1
1

julia> foo2()
1
1
1
1
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.