From: Peter Amstutz Date: Mon, 13 Oct 2014 16:46:15 +0000 (-0400) Subject: Catch ECHILD from os.waitpid() X-Git-Tag: 1.1.0~2032^2~29 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/0fdfa049801418ecd1faf33ec1415f3b689ea761 Catch ECHILD from os.waitpid() --- diff --git a/crunch_scripts/run-command b/crunch_scripts/run-command index 34419b4de4..edc0f5931e 100755 --- a/crunch_scripts/run-command +++ b/crunch_scripts/run-command @@ -28,6 +28,7 @@ import crunchutil.vwd as vwd import argparse import json import tempfile +import errno parser = argparse.ArgumentParser() parser.add_argument('--dry-run', action='store_true') @@ -309,7 +310,14 @@ try: active = 1 while active > 0: - os.waitpid(0, 0) + try: + os.waitpid(0, 0) + except OSError as e: + if e.errno == errno.ECHILD: + # child already exited + pass + else: + raise active = sum([1 if s.poll() is None else 0 for s in subprocesses]) # wait for process to complete. diff --git a/sdk/python/arvados/commands/run.py b/sdk/python/arvados/commands/run.py index e27b3df79c..9df0a84d82 100644 --- a/sdk/python/arvados/commands/run.py +++ b/sdk/python/arvados/commands/run.py @@ -7,12 +7,15 @@ import re import os import stat import put -import arvados.events import time +#import arvados.command.ws as ws +import subprocess arvrun_parser = argparse.ArgumentParser() arvrun_parser.add_argument('--dry-run', action="store_true") +arvrun_parser.add_argument('--local', action="store_true") arvrun_parser.add_argument('--docker-image', type=str, default="arvados/jobs") +arvrun_parser.add_argument('--git-dir', type=str, default="") arvrun_parser.add_argument('command') arvrun_parser.add_argument('args', nargs=argparse.REMAINDER) @@ -116,7 +119,7 @@ def main(arguments=None): component = { "script": "run-command", - "script_version": "bf243e064a7a2ee4e69a87dc3ba46e949a545150", + "script_version": "4f4ad25bf60751a09e316dca8c29cf3628ad7bdc", "repository": "arvados", "script_parameters": { "command": [args.command]+commandargs @@ -141,21 +144,12 @@ def main(arguments=None): if args.dry_run: print(json.dumps(pipeline, indent=4)) + elif args.local: + subprocess.call(["arv-crunch-job", "--job", json.dumps(component), "--git-dir", args.git_dir]) else: api = arvados.api('v1') pi = api.pipeline_instances().create(body=pipeline).execute() - ws = None - def report(x): - if "event_type" in x: - print "\n" - print x - if x["event_type"] == "stderr": - print x["properties"]["text"] - elif x["event_type"] == "update" and x["properties"]["new_attributes"]["state"] in ["Complete", "Failed"]: - ws.close_connection() - - ws = arvados.events.subscribe(api, [["object_uuid", "=", pi["uuid"]], ["event_type", "in", ["stderr", "update"]]], report) - ws.run_forever() + #ws.main(["--pipeline", pi["uuid"]]) if __name__ == '__main__': main()