add lock to call_timeouts to avoid recursive calls in the middle of a set_timeout