summaryrefslogtreecommitdiffstats
path: root/func
diff options
context:
space:
mode:
authorKrzysztof A. Adamski <krzysztofa@gmail.com>2008-06-07 15:04:09 -0400
committerKrzysztof A. Adamski <krzysztofa@gmail.com>2008-06-07 15:04:09 -0400
commitdee316020aaf6e70c909ea177adf2742a33e2b7b (patch)
treeb75b93cf38473d3120103814fecf385e0796358d /func
parentbb80b6e6f10bd97b2926f447e913d8249592c32d (diff)
downloadthird_party-func-dee316020aaf6e70c909ea177adf2742a33e2b7b.tar.gz
third_party-func-dee316020aaf6e70c909ea177adf2742a33e2b7b.tar.xz
third_party-func-dee316020aaf6e70c909ea177adf2742a33e2b7b.zip
Daemonize async jobs on minion.
Diffstat (limited to 'func')
-rw-r--r--func/jobthing.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/func/jobthing.py b/func/jobthing.py
index aa801bc..033368c 100644
--- a/func/jobthing.py
+++ b/func/jobthing.py
@@ -135,9 +135,18 @@ def minion_async_run(retriever, method, args):
pid = os.fork()
if pid != 0:
__update_status(job_id, JOB_ID_RUNNING, -1)
+ os.waitpid(pid, 0)
return job_id
else:
__update_status(job_id, JOB_ID_RUNNING, -1)
+
+ # daemonize!
+ os.umask(077)
+ os.chdir('/')
+ os.setsid()
+ if os.fork():
+ os._exit(0)
+
try:
function_ref = retriever(method)
rc = function_ref(*args)
@@ -146,7 +155,7 @@ def minion_async_run(retriever, method, args):
rc = utils.nice_exception(t,v,tb)
__update_status(job_id, JOB_ID_FINISHED, rc)
- sys.exit(0)
+ os._exit(0)
def job_status(jobid, client_class=None):