def shell_run_with_retry(cmd, retries=1, **kwargs): for i in range(retries + 1): try: if i > 0: tf.logging.info("Retry %d for %s", i, cmd) cloud.shell_run(cmd, **kwargs) return except sp.CalledProcessError as e: if i == retries: raise e
def delete_instance(instance_name): cloud.shell_run(DELETE, name=instance_name)
def kill_python(instance_names): for instance_name in instance_names: cloud.shell_run("ps -aux | grep python | awk '{print $2}' |xargs kill", name=instance_name)