
Hostname = HOOK_JSON.get('host').get('name', None) (HOOK_EVENT, HOOK_OBJECT, HOOK_TEMP_DIR, get_json_hook) However, when it runs as part of the provisioning workflow, it waits on that child process finishing, I don’t understand why.Ĭhild process runs in background and workflow continues without waiting for it to complete When I run this hook from the command line it runs as expected, the parent python script exits and the child process is running in the background. This python script fires off a long running job supposedly in the background and I don’t wish to wait for it to complete before moving on (it includes a few sleep commands). Make the sub-program quit when the main program does.I created a before_provision foreman hook python script.Send a message back from the sub-program to the main program.

If this is the recommended method, I can probably work out what the "-u" does and how to add the parameters for myself. Some research has shown several more sophisticated alternatives, but I have the impression that the latest and most approved method is this one: subprocess.Popen()Īm I correct in thinking that that is the most appropriate way of doing it? Would anyone recommend a different method and why? Simple would be good as I'm a bit of a Python novice.

The simplest way of spawning it might be: result = os.system('python3 sub-program.py file.txt file.txt &') That works fine, but I (eventually!) realised that I could use Python for the sub-program, which would be far preferable, so I have converted it. I'm currently using bash for the sub-program, started with a command and two parameters like this: result = os.system('sub-program.sh file.txt file.txt &')

I have a Python program from which I spawn a sub-program to process some files without holding up the main program.
