Commit c5997795 authored by David Trudgian's avatar David Trudgian
Browse files

Correct callback trace file writing

parent f9eb6015
......@@ -6,8 +6,6 @@ import datetime
import logging
import re
from .templates import template_env
logger = logging.getLogger(__name__)
class BaseExecutor:
......@@ -35,6 +33,8 @@ class BaseExecutor:
self.logdir = logdir
self.start_trace()
def start_trace(self):
......@@ -52,9 +52,9 @@ class BaseExecutor:
def write_trace(self, msg):
trace_path = os.path.join(self.logdir, 'trace.txt')
trace_file = open(trace_path, 'w', buffering = False)
trace_file = open(trace_path, 'a', buffering = False)
trace_file.write("msg")
trace_file.write(msg)
trace_file.close()
......@@ -91,16 +91,16 @@ class BaseExecutor:
end
)
self.write_trace(summary_line)
return summary_line
@abstractmethod
def run(self):
pass
@abstractmethod
def run(self):
pass
@abstractmethod
def run_cmd(self):
pass
@abstractmethod
def run_cmd(self):
pass
......@@ -141,7 +141,7 @@ class SrunExecutor(BaseExecutor):
for cmd_idx, cmd in enumerate(self.commands):
logger.debug(" - Task %d is waiting in the pool" % cmd_idx)
p.apply_async( self.wrap_cmd, [cmd_idx])
p.apply_async( self.wrap_cmd, [cmd_idx], callback=self.write_trace )
p.close()
p.join()
......@@ -150,7 +150,7 @@ class SrunExecutor(BaseExecutor):
def run_cmd(self, cmd, stderr_file, stdout_file):
cpus_per_task = self.params.vals['cpus_per_task']
srun_cmd = "srun -n1 -c%d '%s'" % ( cpus_per_task, cmd['__command']['value'])
srun_cmd = "srun -n1 -c%d %s" % ( cpus_per_task, cmd['__command']['value'])
ret = call(srun_cmd, shell=True, stderr=stderr_file,
stdout=stdout_file, env=os.environ)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment