code: def wait(self=None, period=10, callback=None, *args, **kwargs):
          
          while self.status not in [
              TaskStatus.COMPLETED,
              TaskStatus.FAILED,
              TaskStatus.ABORTED
          ]:
              self.reload()
              time.sleep(period)
  
          if callback:
              return callback(*args, **kwargs)
docs: Wait until task is complete
          :param period: Time in seconds between reloads
          :param callback: Function to call after the task has finished,
              arguments and keyword arguments can be provided for it
          :return: Return value of provided callback function or None if a
              callback function was not provided