Skip to content

Commit

Permalink
finally it works, damned timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandruBurlacu committed Mar 8, 2018
1 parent 2641a8f commit bb2e2cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 43 deletions.
21 changes: 5 additions & 16 deletions lab2/lib/lab2.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,12 @@ defmodule Lab2 do

{urls, key} = get_urls_and_key()

IO.inspect urls

# data = Task.async(fn -> HTTPotion.get("#{service_root}/ofzvwicmsn",
# headers: ["session": key]) end)

# Task.await(data, 30001).body

tasks = Enum.map(urls, fn url ->
Task.async(fn -> HTTPotion.get("#{@service_root}#{url["path"]}",
headers: ["session": key]) end)
tasks = Enum.map(urls, fn url ->
Task.async(fn ->
HTTPotion.get "#{@service_root}#{url["path"]}", [headers: ["session": key], timeout: 50_000]
end)
end)
# :timer.sleep(29990)
bodies = Enum.map(tasks, &Task.await(&1))

# bodies = Task.async_stream(urls, fn url -> HTTPotion.get("#{service_root}#{url["path"]}",
# headers: ["session": key]) end, timeout: 50000)
# |> Enum.to_list
bodies = Enum.map(tasks, &Task.await(&1, 50_000))

bodies
end
Expand Down
27 changes: 0 additions & 27 deletions lab2/lib/processes.ex

This file was deleted.

0 comments on commit bb2e2cb

Please sign in to comment.