summaryrefslogtreecommitdiffstats
path: root/rpmci/subtask.py
diff options
context:
space:
mode:
Diffstat (limited to 'rpmci/subtask.py')
-rw-r--r--rpmci/subtask.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/rpmci/subtask.py b/rpmci/subtask.py
index e97279e..a3902be 100644
--- a/rpmci/subtask.py
+++ b/rpmci/subtask.py
@@ -39,29 +39,37 @@ def prepare_task_logfile(taskid):
def _init_task_run(taskid, argv, cwd):
log_path = prepare_task_logfile(taskid)
- logging.info("Running task %r synchronously, cwd=%r args=%r" % (taskid, cwd, argv))
- return log_path
+ logging.info("Calling task %r synchronously, cwd=%r args=%r" % (taskid, cwd, argv))
+ f = open(log_path, 'w')
+ f.write("Logfile for process cwd=%r args=%r\n" % (cwd, argv))
+ f.flush()
+ return (log_path, f)
def spawn_sync(taskid, argv, cwd=None):
- log_path = _init_task_run(taskid, argv, cwd)
- f = open(log_path, 'w')
+ (log_path, f) = _init_task_run(taskid, argv, cwd)
nullf = open(os.devnull, 'w')
try:
- subprocess.check_call(argv, cwd=cwd, stdin=nullf, stdout=f, stderr=f)
+ proc = subprocess.Popen(argv, cwd=cwd, stdin=nullf, stdout=f, stderr=f)
+ logging.info("Started subtask %s, pid=%d" % (taskid, proc.pid))
+ proc.wait()
except subprocess.CalledProcessError, e:
+ logging.exception(e)
+ f.write("Failed: %r" % (e, ))
f.close()
shutil.move(log_path, _failed_path)
raise e
f.close()
def spawn_sync_get_output(taskid, argv, cwd=None):
- log_path = _init_task_run(taskid, argv, cwd)
- f = open(log_path, 'w')
+ (log_path, f) = _init_task_run(taskid, argv, cwd)
nullf = open(os.devnull, 'w')
try:
proc = subprocess.Popen(argv, cwd=cwd, stdin=nullf, stdout=subprocess.PIPE, stderr=f)
+ logging.info("Started subtask %s, pid=%d" % (taskid, proc.pid))
output = proc.communicate()[0]
except subprocess.CalledProcessError, e:
+ logging.exception(e)
+ f.write("Failed: %r" % (e, ))
f.close()
shutil.move(log_path, _failed_path)
raise e