<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def wait_for_completion(self, job_id, timeout=None):
 """ Wait for the job given by job_id to change to COMPLETED or CANCELED. Raises a iceqube.exceptions.TimeoutError if timeout is exceeded before each job change. :param job_id: the id of the job to wait for. :param timeout: how long to wait for a job state change before timing out. """

        while 1:
            job = self.wait(job_id, timeout=timeout)
            if job.state in [State.COMPLETED, State.FAILED, State.CANCELED]:
                return job
            else:
                continue