def _process_state_change_events():
    """Process events relating to the overall state of SDP.

    This function starts and event loop which continually checks for
    and responds to SDP state change events.
    """
    sdp_state = SDPState()
    service_states = get_service_state_list()
    state_events = sdp_state.get_event_queue(subscriber=__service_name__)
    state_is_off = sdp_state.current_state == 'off'

    counter = 0
    while True:
        time.sleep(0.1)
        if not state_is_off:

            # *Hack* to avoid problems with historical events not being
            # correctly handled by EventQueue.get(), replay old events every
            # 10s
            # - see issue #54
            if counter % 1000 == 0:
                LOG.debug('Checking published events ... %d', counter / 1000)
                _published_events = state_events.get_published_events(
                    process=True)
                for _state_event in _published_events:
                    _process_event(_state_event, sdp_state, service_states)
            else:
                _state_event = state_events.get()
                if _state_event:
                    _process_event(_state_event, sdp_state, service_states)
                    state_is_off = sdp_state.current_state == 'off'
            counter += 1
Process events relating to the overall state of SDP.

    This function starts and event loop which continually checks for
    and responds to SDP state change events.