You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to keep low latency tasks on the interactive thread pool and spawn heavier tasks on the default threadpool. However, this still doesn't seem to work with the most recent release candidate:
The following is a MWE server script. Run with julia +beta -t1,1
using Dates, HTTP
const ROUTER = HTTP.Router()
functionlow_latency(req)
@info"$(now())> $(Threads.threadpool()) tid: $(Threads.threadid())"return"Done with low latency task"end
HTTP.register!(ROUTER, "GET", "/low", low_latency)
functionhigh_latency(req)
Threads.@spawn:defaultbegin
s =sum(randn(10^8))
@info"$(now())> $(Threads.threadpool()) tid: $(Threads.threadid()), sum = $s"return"Done with high latency task"endend
HTTP.register!(ROUTER, "GET", "/high", high_latency)
functionrequestHandler(req)
resp =ROUTER(req)
return HTTP.Response(200, resp)
end
HTTP.serve(requestHandler, "0.0.0.0", 7777)
Calling the /low route works fine, but on calling the /high route, I get:
Request handlers must be of the form f(::Request) -> Response), and you're violating that for the high latency; instead you want:
function high_latency(req)
fetch(Threads.@spawn :default begin
s = sum(randn(10^8))
@info "$(now())> $(Threads.threadpool()) tid: $(Threads.threadid()), sum = $s"
return "Done with high latency task"
end)
end
I want to keep low latency tasks on the interactive thread pool and spawn heavier tasks on the default threadpool. However, this still doesn't seem to work with the most recent release candidate:
The following is a MWE server script. Run with
julia +beta -t1,1
Calling the
/low
route works fine, but on calling the/high
route, I get:Is this user error or a bug?
Versions
The text was updated successfully, but these errors were encountered: