def _wait_for_task_ended(self):
try:<EOL><INDENT>waiter = self.client.get_waiter('<STR_LIT>')<EOL>waiter.config.max_attempts = sys.maxsize  <EOL>waiter.wait(jobs=[self.jobId])<EOL><DEDENT>except ValueError:<EOL><INDENT>retry = True<EOL>retries = <NUM_LIT:0><EOL>while retries < self.max_retries and retry:<EOL><INDENT>self.log.info('<STR_LIT>', retries)<EOL>response = self.client.describe_jobs(<EOL>jobs=[self.jobId]<EOL>)<EOL>if response['<STR_LIT>'][-<NUM_LIT:1>]['<STR_LIT:status>'] in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>retry = False<EOL><DEDENT>sleep(<NUM_LIT:1> + pow(retries * <NUM_LIT:0.1>, <NUM_LIT:2>))<EOL>retries += <NUM_LIT:1><EOL><DEDENT><DEDENT>
Try to use a waiter from the below pull request

    * https://github.com/boto/botocore/pull/1307

If the waiter is not available apply a exponential backoff

    * docs.aws.amazon.com/general/latest/gr/api-retries.html