Hi all I have this piece of multithreaded code, however it is only executing the f

Hi all I have this piece of multithreaded code, however it is only executing the first queue in _queues. Could anyone give any pointer :slightly_smiling_face: ?

function execute_queues!()
    @async begin
        amqp_connection!(_conn_def) do conn
            amqp_channel!(conn) do chan
                @sync for queue in _queues
                    @async Threads.@spawn queue(chan)
                end
            end
        end
    end
end

Note that the original poster on Slack cannot see your response here on Discourse. Consider transcribing the appropriate answer back to Slack, or pinging the poster here on Discourse so they can follow this thread.
(Original message :slack:) (More Info)

without knowing what you do with amqp_connection! and amqp_channel! and _queue … but you in that function

  1. start an @async task that
  2. starts a for loop starting @async tasks each of which
  3. @spawns a task …

so you can – for debugging – try first without the two @async calls (you can reintroduce them later) and return a Vector{Task}, which then you can look at, something like that:

function execute_queues!()
    ts = Task[]
    amqp_connection!(_conn_def) do conn
        amqp_channel!(conn) do chan
            @sync for queue in _queues
                push!(ts, Threads.@spawn queue(chan))
            end
        end
    end
    return ts
end

This should show you if any of the spawned tasks have failed and eventually you can look at their stack traces.

1 Like