code: def main():
      
      # Parse command line args.
      _parse_args()
      LOG.info("Starting: %s", __service_id__)
  
      # Subscribe to state change events.
      # FIXME(BMo) This API is unfortunate as it looks like we are only
      # subscribing to sdp_state events.
      LOG.info('Subscribing to state change events (subscriber = %s)',
               __service_name__)
      sdp_state = SDPState()
      _ = sdp_state.subscribe(subscriber=__service_name__)
  
      # Initialise the service.
      _ = _init(sdp_state)
      LOG.info('Finished initialising!')
  
      # Enter a pseudo event-loop (using Sched) to monitor for state change
      # events
      # (Also random set services into a fault or alarm state if enabled)
      LOG.info('Responding to state change events ...')
      try:
          _process_state_change_events()
      except ValueError as error:
          LOG.critical('Value error: %s', str(error))
      except KeyboardInterrupt as err:
          LOG.debug('Keyboard Interrupt %s', err)
      LOG.info('Exiting!')
docs: Merge temp_main and main.