python - Flask script, no response after running for a while
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-18 10:56:36
0
1
2186

code show as below:

# -*- coding:utf-8 -*-
import flask
import subprocess

app = flask.Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"

@app.route("/api/clear",methods=['POST'])
def clear():
    domains = flask.request.form
    for k in domains:
        if domains[k].strip() != '':
            #os.system('rm -rf /data/proxy_cache_dir/'+ domains[k])
            subprocess.call('rm -rf /data/proxy_cache_dir/' + domains[k], shell=True)

    return domains['domain']

@app.route("/apinew/clear",methods=['POST'])
def new_clear():
    domains = flask.request.form
    for k in domains:
        if domains[k].strip() != '':
            #os.system('rm -rf /data/proxy_cache_dir/'+ domains[k])
            subprocess.call('rm -rf /data/proxy_cache_dir/' + domains[k], shell=True)

    return domains['0']

if __name__ == "__main__":
    app.run(host='0.0.0.0',port=5000)

This is the same piece of code that has been running well on a previous server. Now running on Baidu Cloud Server, it will become unresponsive after a while, so you need to shut down the process and run it again. Before the subprocess.call method, using os.system will have the same problem, and the normal running time will be shorter. I hope you guys can give me some advice on where to start.

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(1)
迷茫

1. Did an exception occur here?
2. Did this command run successfully?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template