Elixir Task.async_stream returns weird output

Using Task.async_stream is just fine in my uploading many files to S3.

Trying to use it in the download_many function, which takes a list of url keywords and ids. When I run the download_many function in the iex session, it returns the following output:

iex(1)> Karma.S3.download_many(1)
    #Function<1.112846234/2 in Task.build_stream/3>
    #Function<1.112846234/2 in Task.build_stream/3>

      

Here is the function:

def download_many(_urls) do
    urls = [
      "5": "https://engine-image-uploads.s3.amazonaws.com/engine-image-uploads/d4a9f8adb58b4e0b83c47e8f3b21d421-fillable.pdf",
      "3": "https://engine-image-uploads.s3.amazonaws.com/engine-image-uploads/ccd6d66cb4304b369a025efe3b26e68b-fillable.pdf"
    ]

   ops = [max_concurrency: System.schedulers_online() * 3, timeout: 20000]

   tasks = Task.async_stream(urls, &download_with_id/1, ops)
    |> Enum.to_list()
    IO.inspect tasks
  end

 def download_with_id({id, url}) do
    file_destination = System.cwd() <> "/tmp/altered_document_" <> Atom.to_string(id) <> ".pdf"
    download(url, file_destination)
    |> Tuple.insert_at(2, id)
  end

      

And the link to the file: https://github.com/karmaradio/karma/blob/async-download_many/lib/S3.ex#L58

I don't understand the result: #Function<1.112846234/2 in Task.build_stream/3>

Has anyone experienced something similar?

Thanks in advance!

+3


source to share


1 answer


Answered in this comment by dogbert



0


source







All Articles