# File lib/mcollective/agents.rb, line 118
    def dispatch(request, connection)
      Log.debug("Dispatching a message to agent #{request.agent}")

      Thread.new do
        begin
          agent = PluginManager["#{request.agent}_agent"]

          Timeout::timeout(agent.timeout) do
            replies = agent.handlemsg(request.payload, connection)

            # Agents can decide if they wish to reply or not,
            # returning nil will mean nothing goes back to the
            # requestor
            unless replies == nil
              yield(replies)
            end
          end
        rescue Timeout::Error => e
          Log.warn("Timeout while handling message for #{request.agent}")
        rescue Exception => e
          Log.error("Execution of #{request.agent} failed: #{e}")
          Log.error(e.backtrace.join("\n\t\t"))
        end
      end
    end