Are timeouts paused when my computer sleeps?

I’m writing a genserver for a multiplayer game. I want the genserver to shutdown after a period of inactivity so I’m passing a timeout parameter in the call back responses e.g.

  def handle_call(:get_game, _from, game) do
    {:reply, summarise(game), game, @timeout}
  end

...

  def handle_info(:timeout, game) do
    {:stop, {:shutdown, :timeout}, game}
  end

Say the timeout is 10 mins. I start a genserver then put my computer to sleep and come back 20 minutes later. When I wake my computer I find the genserver is still running.

Is this expected behaviour or does the sleeping action break my timeout?

I’m not sure but maybe it’s related with the runtime. When your pc goes to sleep the runtime is paused too.
I would check if the runtime actually increases when put to sleep.

{runtime, _} = :erlang.statistics(:runtime)

Like checking if the light goes off in a refrigerator. We will never know :wink: j/k

Really helpful that you provided the code snippet. Thanks.