How to process data asynchronously in Elixir?

Hi @NobbZ, @lucaong

I have used following approach

Controller

def create(conn, %{"file" => %Plug.Upload{path: fullpath, content_type: "text/csv"}, "email" => email}) do
    conn
      |> render_json_response({:ok, %{message: "Request Initiated"}})
    CSVParser.call(fullpath, email)
  end

CSVParser.ex

def call(csv_path, email) do
    task = Task.async(fn -> do_async_task(csv_path, email) end)
    Task.await(task, :infinity)
  end

  def do_async_task(csv_path, email) do
    csv_path
      |> read_csv
      |> dump_to_csv
      |> add_attachment
      |> Email.create(email)
      |> Email.send_email
  end

But If i hit the api simultaneously the other request is not returning Request Initiated they just keep waiting.

Also I am getting this error message

expected action/2 to return a Plug.Conn, all plugs must receive a connection (conn) and return a connection.