subprocess.Popen then release

37 views
Skip to first unread message

lucas

unread,
May 24, 2019, 2:13:22 PM5/24/19
to web2py-users
hello one and all,

ok, using python 2.7 and web2py 2.18.5 on centos or raspbian linux.  is there a way to start a python script file, a file that runs python all on its own from the command line interface, and start or spawn it under a web2py controller function, have web2py immediately, completely, and safely release from the running script, allow the script to continue to run, and then just return whatever html back to the user?  so the script will still be running even after the controller does its response and such.  and I wouldn't mind during the spawning process would return the pid when its originally spawned so I can kill it later on.

I guessing I would use subprocess.Popen but I can't seem to get web2py to immediately return and I would like verification that doing this won't hurt the multiprocessing or threads, or create some kind of instability in web2py or the server, or any of that kind of mess like that.

thank you in advance, Lucas


Dave S

unread,
May 24, 2019, 5:01:53 PM5/24/19
to web2py-users

Why do you need web2py to launch the script?  Is this something that should be running forever?  I'd look at the Rasbian startup tools (is that systemd in that environment?).  If it has to start in response to a request, but run for donkey's years after that, I'd look at having the front end take care of it (I think you said Nginx in another thread; with uwsgi?).  Otherwise, I'd make it a scheduler task, and set the timeout as a big number.

/dps

lucas

unread,
May 24, 2019, 5:50:13 PM5/24/19
to web2py-users
yeah, I thought of doing it as a scheduled task, but its really best to be triggered by a web2py event and then collect data off of an a2d convertor and populate a db with pure data.  so that's why it isn't a true daemon, but I might go in that direction and just have crond trigger it.
Reply all
Reply to author
Forward
0 new messages