X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/3af38eca348413c6f11f6526b2ee2ca7cb53e348..58b12d248ed05f8b75b16cee33b0e153e7be71f6:/sdk/cwl/arvados_cwl/executor.py diff --git a/sdk/cwl/arvados_cwl/executor.py b/sdk/cwl/arvados_cwl/executor.py index c1f2b54744..c358426166 100644 --- a/sdk/cwl/arvados_cwl/executor.py +++ b/sdk/cwl/arvados_cwl/executor.py @@ -59,6 +59,7 @@ class RuntimeStatusLoggingHandler(logging.Handler): def __init__(self, runtime_status_update_func): super(RuntimeStatusLoggingHandler, self).__init__() self.runtime_status_update = runtime_status_update_func + self.updatingRuntimeStatus = False def emit(self, record): kind = None @@ -66,22 +67,27 @@ class RuntimeStatusLoggingHandler(logging.Handler): kind = 'error' elif record.levelno >= logging.WARNING: kind = 'warning' - if kind is not None: - log_msg = record.getMessage() - if '\n' in log_msg: - # If the logged message is multi-line, use its first line as status - # and the rest as detail. - status, detail = log_msg.split('\n', 1) - self.runtime_status_update( - kind, - "%s: %s" % (record.name, status), - detail - ) - else: - self.runtime_status_update( - kind, - "%s: %s" % (record.name, record.getMessage()) - ) + if kind is not None and self.updatingRuntimeStatus is not True: + self.updatingRuntimeStatus = True + try: + log_msg = record.getMessage() + if '\n' in log_msg: + # If the logged message is multi-line, use its first line as status + # and the rest as detail. + status, detail = log_msg.split('\n', 1) + self.runtime_status_update( + kind, + "%s: %s" % (record.name, status), + detail + ) + else: + self.runtime_status_update( + kind, + "%s: %s" % (record.name, record.getMessage()) + ) + finally: + self.updatingRuntimeStatus = False + class ArvCwlExecutor(object): """Execute a CWL tool or workflow, submit work (using either jobs or @@ -469,7 +475,7 @@ http://doc.arvados.org/install/install-api-server.html#disable_api_methods with final.open("cwl.output.json", "w") as f: res = str(json.dumps(outputObj, sort_keys=True, indent=4, separators=(',',': '), ensure_ascii=False)) - f.write(res) + f.write(res) final.save_new(name=name, owner_uuid=self.project_uuid, storage_classes=storage_classes, ensure_unique_name=True)