def _handle_timeouts(self):
        now = self.clock.time_msec()

        with Measure(self.clock, "presence_handle_timeouts"):
            # Fetch the list of users that *may* have timed out. Things may have
            # changed since the timeout was set, so we won't necessarily have to
            # take any action.
            users_to_check = self.wheel_timer.fetch(now)

            states = [
                self.user_to_current_state.get(
                    user_id, UserPresenceState.default(user_id)
                )
                for user_id in set(users_to_check)
            ]

            timers_fired_counter.inc_by(len(states))

            changes = handle_timeouts(
                states,
                is_mine_fn=self.hs.is_mine_id,
                user_to_num_current_syncs=self.user_to_num_current_syncs,
                now=now,
            )

        preserve_fn(self._update_states)(changes)
Checks the presence of users that have timed out and updates as
dataset/ETHPy150Open matrix-org/synapse/synapse/handlers/presence.py/PresenceHandler._handle_timeouts