Elixir Sleep / Wait for 1 Second

Solution 1:

Timer uses milliseconds not seconds, update to:

IO.puts "foo" ; :timer.sleep(1000); IO.puts "bar"

Documentation of :timer in Erlang's doc:

Suspends the process calling this function for Time amount of milliseconds and then returns ok, or suspend the process forever if Time is the atom infinity. Naturally, this function does not return immediately.

http://erlang.org/doc/man/timer.html#sleep-1

Solution 2:

Since Elixir 1.3 you can use Process.sleep/1:

Process.sleep(1000)

The argument is in milliseconds.