How to sleep / wait for one second?
Best I could find was something like this (in iex):
IO.puts "foo" ; :timer.sleep(1); IO.puts "bar"
But both of my puts happen with no delay.
How to sleep / wait for one second?
Best I could find was something like this (in iex):
IO.puts "foo" ; :timer.sleep(1); IO.puts "bar"
But both of my puts happen with no delay.
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.
:timer.sleep(:timer.seconds(1))
–
Zashin © 2022 - 2024 — McMap. All rights reserved.
Process.sleep
instead of calling erlang. – Phalanx