We want to prevent race conditions on remote workers serving requests from HTTP.jl on porocess 1. We are trying to stack the “requests” in a channel… trying to figure out how to do this with remotecall_fetch and Channels ….
We need the Process 1 to wait for results … but the worker can only do 1 request at a time … so far this issue is put! waits for the channel to take the request but does “not wait for the results"
Many many thanks ! Chuck
Process 1 - API Gateway
function handle_qreq (res, scen_cubes) = remotecall_fetch(query_cubes_task, 2 , qreq) # ==> need this to be synchronous and wait for response end
Worker 2 - Query Service
const query_channel = Channel(1) # ==> channel of 1 so that this worker only does 1 thing at a time sequentially function start_query_listening() try while true qreq = take!(query_channel) # => forever take! work off the channel res, scen_cubes = query_cubes(qreq) end catch ex println(stacktrace()) println(stacktrace(catch_backtrace())) end end function query_cubes_task(qry_req::QReq) put!(query_channel, qry_req) # => put! Does not return the data to Worker 1 … put waits in the channel to START work not Finish end
How can we server synchronous requests that get dispatched to worker processes from HTTP.jl … the same worker may get 2 requests simultaneously. Each worker needs a “queue” of work and the main caller needs to wait for response. Maybe channels are not the answer