From e9c0ab574e6bae899556e82d4ba0da439a976093 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Mon, 7 Jul 2014 08:59:24 -0400 Subject: [PATCH] run-command retry after exception when writing output to keep. no issue # --- crunch_scripts/run-command | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/crunch_scripts/run-command b/crunch_scripts/run-command index 6335523a74..a8aae24f16 100755 --- a/crunch_scripts/run-command +++ b/crunch_scripts/run-command @@ -7,11 +7,14 @@ import subprocess import sys import shutil import subst +import time os.umask(0077) t = arvados.current_task().tmpdir +api = arvados.api('v1') + os.chdir(arvados.current_task().tmpdir) os.mkdir("tmpdir") os.mkdir("output") @@ -71,13 +74,20 @@ finally: out = arvados.CollectionWriter() out.write_directory_tree(".", max_manifest_depth=0) - outuuid = out.finish() - arvados.api('v1').job_tasks().update(uuid=arvados.current_task()['uuid'], - body={ - 'output':outuuid, - 'success': (rcode == 0), - 'progress':1.0 - }).execute() + done = False + while not done: + try: + outuuid = out.finish() + api.job_tasks().update(uuid=arvados.current_task()['uuid'], + body={ + 'output':outuuid, + 'success': (rcode == 0), + 'progress':1.0 + }).execute() + done = True + except Exception as e: + print("run-command: caught exception: {}".format(e)) + time.sleep(5) if rcode == 0: os.chdir("..") -- 2.39.5