code: def monitor_resource_sync_state(resource, callback, exit_event=None):
      
      exit_event = exit_event or AsyncEvent()
      callback(False)        # Initial condition, assume resource is not connected
  
      while not exit_event.is_set():
          # Wait for resource to be synced
          yield until_any(resource.until_synced(), exit_event.until_set())
          if exit_event.is_set():
              break       # If exit event is set we stop without calling callback
          else:
              callback(True)
  
          # Wait for resource to be un-synced
          yield until_any(resource.until_not_synced(), exit_event.until_set())
          if exit_event.is_set():
              break       # If exit event is set we stop without calling callback
          else:
              callback(False)
docs: Coroutine that monitors a KATCPResource's sync state.
  
      Calls callback(True/False) whenever the resource becomes synced or unsynced. Will
      always do an initial callback(False) call. Exits without calling callback() if
      exit_event is set