Skip to content

Commit

Permalink
Merge pull request #5483 from oliver-sanders/file_open_efficiency
Browse files Browse the repository at this point in the history
task_job_mgr: move compute out of open call
  • Loading branch information
hjoliver authored Apr 25, 2023
2 parents d34ae53 + 4f63139 commit 29b1430
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cylc/flow/task_job_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,11 +628,12 @@ def _job_cmd_out_callback(workflow, itask, cmd_ctx, line):
line = "%s %s" % (timestamp, content)
job_activity_log = get_task_job_activity_log(
workflow, itask.point, itask.tdef.name)
if not line.endswith("\n"):
line += "\n"
line = host + line
try:
with open(os.path.expandvars(job_activity_log), "ab") as handle:
if not line.endswith("\n"):
line += "\n"
handle.write((host + line).encode())
with open(os.path.expandvars(job_activity_log), "a") as handle:
handle.write(line)
except IOError as exc:
LOG.warning("%s: write failed\n%s" % (job_activity_log, exc))
LOG.warning(f"[{itask}] {host}{line}")
Expand Down

0 comments on commit 29b1430

Please sign in to comment.