def wait_for_tasks_to_complete(batch_service_client, job_ids, timeout):
timeout_expiration = datetime.datetime.now() + timeout<EOL>print("<STR_LIT>".format(timeout), end='<STR_LIT>')<EOL>while datetime.datetime.now() < timeout_expiration:<EOL><INDENT>print('<STR_LIT:.>', end='<STR_LIT>')<EOL>sys.stdout.flush()<EOL>for (job_id, _) in job_ids:<EOL><INDENT>tasks = batch_service_client.task.list(job_id)<EOL>incomplete_tasks = [task for task in tasks if<EOL>task.state != batchmodels.TaskState.completed]<EOL>if incomplete_tasks:<EOL><INDENT>break<EOL><DEDENT><DEDENT>if not incomplete_tasks:<EOL><INDENT>print()<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>time.sleep(<NUM_LIT:1>)<EOL><DEDENT><DEDENT>raise RuntimeError("<STR_LIT>"<EOL>"<STR_LIT>" + str(timeout))<EOL>
Returns when all tasks in the specified job reach the Completed state.

    :param batch_service_client: A Batch service client.
    :type batch_service_client: `azure.batch.BatchServiceClient`
    :param str job_id: The id of the job whose tasks should be to monitored.
    :param timedelta timeout: The duration to wait for task completion. If all
    tasks in the specified job do not reach Completed state within this time
    period, an exception will be raised.