summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alvarez Piedehierro <palvarez89@gmail.com>2019-05-16 09:01:52 +0000
committerPedro Alvarez Piedehierro <palvarez89@gmail.com>2019-05-16 09:01:52 +0000
commit87d97ba405039ac3c45a18ee4e310a77ff507fb5 (patch)
tree290a346ce8f6878dc002298586bcfbd8d12ee711
parent7ee32989f7f320a0f7f7c00565ca09c5cf43b512 (diff)
parentcf9d17ce9da862e1b70f83bab70c432f190fcea6 (diff)
downloadlorry-controller-87d97ba405039ac3c45a18ee4e310a77ff507fb5.tar.gz
Merge branch 'benbrown/clean-removed-jobs' into 'master'
Reap children of spawned subprocesses Closes lorry#2 See merge request baserock/lorry-controller!2
-rwxr-xr-xlorry-controller-minion9
-rw-r--r--lorrycontroller/statedb.py4
2 files changed, 8 insertions, 5 deletions
diff --git a/lorry-controller-minion b/lorry-controller-minion
index 72f1a39..9eb6657 100755
--- a/lorry-controller-minion
+++ b/lorry-controller-minion
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright (C) 2014 Codethink Limited
+# Copyright (C) 2014-2019 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@ import os
import platform
import random
import select
+import signal
import subprocess
import tempfile
import time
@@ -171,7 +172,8 @@ class MINION(cliapp.Application):
argv,
stdin=devnull,
stdout=pipe[1],
- stderr=subprocess.STDOUT)
+ stderr=subprocess.STDOUT,
+ preexec_fn=os.setsid)
os.close(pipe[1])
devnull.close()
@@ -212,7 +214,8 @@ class MINION(cliapp.Application):
return stdout, stderr, exit
def kill_job(self):
- self.process.kill()
+ pgid = os.getpgid(self.process.pid)
+ os.killpg(pgid, signal.SIGKILL)
return self.process.wait()
def update_webapp_about_job(self, job_spec, stdout, stderr, exit):
diff --git a/lorrycontroller/statedb.py b/lorrycontroller/statedb.py
index 17b31dd..b2bac7e 100644
--- a/lorrycontroller/statedb.py
+++ b/lorrycontroller/statedb.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2017 Codethink Limited
+# Copyright (C) 2014-2018 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -645,7 +645,7 @@ class StateDB(object):
yield row[0], row[1], row[2]
def remove_job(self, job_id):
- logging.debug('StateDB.append_to_job_output(%r,..) called', job_id)
+ logging.debug('StateDB.remove_job(%r,..) called', job_id)
assert self.in_transaction
c = self.get_cursor()
c.execute('DELETE FROM jobs WHERE job_id = ?', (job_id,))