I have an AngularJS http post request made by the client that posts to handleRequest.py on the server. Depending on the data posted, it then runs various database queries and procedures as detached sub-processes.
The code for generating the sub-process looks like:
CREATE_NEW_PROCESS_GROUP = 0x00000200
DETACHED_PROCESS = 0x00000008
p = subprocess.Popen( [
sys.executable,
"executeOracleProcedure.py"
] + args,
stdout=logfile, stderr=logfile, stdin=logfile,
creationflags=DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP)
handleRequest.py then responds by printing a response to the client telling them that they executed the procedure.
print("Content-type: application/json")
print("Status: " + status + " " + status_text + "\n")
print(json)
handleRequest.py should then exit. Leaving its sub-processes running as it takes a long time for the procedures to run.
After adding some logging I have confirmed that the sub-process seems to be running. However it seems the client still waits (and eventually timeouts as the procedure takes ages) for the sub-process to complete despite handleRequest.py seemingly ending.
I have tried bombing it with sys.stdout.flush() and sys.exit() to try and make 100% sure that handleRequest.py is giving the correct output and exiting and as far as I can tell it is. So do I get get my client side to stop waiting on a response as soon as it gets the printed response?