Create a receive with a large timeout

receive do
      {event} ->
        IO.puts "event"
      duration ->
        IO.puts "duration or timeout"

i have a spawn process which is implemented like that. duration can be equal to 31536000000 ms which represents a year in ms. It works well for a day, a week, a month but not more. How can i get this thing work? the error I receive is

[error] Process #PID<0.295.0> raised an exception
** (ErlangError) erlang error: :timeout_value

Thank you for the help

1 Like

If you check in the Erlang documentation in the reference manual on the receive expression,, it explicitly says "ExprT is to evaluate to an integer. The highest allowed value is 16#FFFFFFFF, that is, the value must fit in 32 bits." and that ExprT is in milliseconds. This means that if you want a longer time then you will have to implement it in a sequence or loop of receive.