def wait_for_job_status(self, job_status, max_attempts=<NUM_LIT:50>):
<EOL>if self.recorder.current_cassette.is_recording():<EOL><INDENT>request_interval = <NUM_LIT:5><EOL><DEDENT>else:<EOL><INDENT>request_interval = <NUM_LIT><EOL><DEDENT>n = <NUM_LIT:0><EOL>while True:<EOL><INDENT>sleep(request_interval)<EOL>n += <NUM_LIT:1><EOL>job_status = self.zenpy_client.job_status(id=job_status.id)<EOL>if job_status.progress == job_status.total:<EOL><INDENT>return job_status<EOL><DEDENT>elif n > max_attempts:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT><DEDENT>
Wait until a background job has completed.