code: def retry_when_service_down(func):
      
      def retry_function(*args, **kwds):
          showed_status_msg = False
          status_watcher = args[0]
          while True:
              try:
                  result = func(*args, **kwds)
                  if showed_status_msg:
                      status_watcher.set_status_message('')
                  return result
              except DataServiceError as dse:
                  if dse.status_code == 503:
                      if not showed_status_msg:
                          message = SERVICE_DOWN_MESSAGE.format(datetime.datetime.utcnow())
                          status_watcher.set_status_message(message)
                          showed_status_msg = True
                      time.sleep(SERVICE_DOWN_RETRY_SECONDS)
                  else:
                      raise
      return retry_function
docs: Decorator that will retry a function while it fails with status code 503
      Assumes the first argument to the fuction will be an object with a set_status_message method.
      :param func: function: will be called until it doesn't fail with DataServiceError status 503
      :return: value returned by func