How do you run a script in flask without making the front end unresponsive?

I ran a shell script in flask, and the problem now is that this shell script takes a long time and causes the front-end web to become unresponsive during the run, so we have to wait until the script is finished. Is there any way to solve it? I"ve tried that using ajax, doesn"t work, because calling ajax"s url to execute the script still causes the page to get stuck. I have also tried to open multithreaded app.run (thread=true), which can be solved, but I need to open a new web page. I would like to ask if there is a better way. In addition, this script only runs in the background, and the relevant echo does not need to be rendered to the front end.

Mar.28,2021

any problem encountered in software engineering can be solved by adding an intermediate layer

you can use the method described in @ xdd1874 . You can use nohup, anyway, as long as it starts your shell.


you can leave the execution of the shell script to celery.

http://flask.pocoo.org/docs/1.


flask view calls subprocess.Popen to execute the script, and subprocess generates a child process to execute the script, which can be returned immediately

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b362d1-2bfd6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b362d1-2bfd6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?