import falcon
global_var=False
class set_gv(object):
def on_get(self, req, res):
"""Handles all GET requests."""
res.status = falcon.HTTP_200 # This is the default status
global global_var
global_var=not global_var
res.body = (str(global_var))
class ask_gv(object):
def on_get(self, req, res):
"""Handles all GET requests."""
res.status = falcon.HTTP_200 # This is the default status
res.body = str(global_var)
# Create the Falcon application object
app = falcon.API()
# Instantiate the TestResource class
set = set_gv()
get = ask_gv()
# Add a route to serve the resource
app.add_route('/set', set)
app.add_route('/get', get)
我正在使用带有 gunicorn 和以上代码的 Falcon 框架来托管一个 API 来保存一个变量并使用带有命令的 API 调用来更改和检索它
`gunicorn -b 0.0.0.0:5000 main:app --reload`
当我http://localhost/set
正确打开它时,它会更改并返回值,但一段时间后我在控制台上收到以下错误并且变量值被重置
[CRITICAL] WORKER TIMEOUT (pid:8545)
有关如何解决此问题的任何帮助。提前致谢。