当我使用torado+flask创建一个web应用程序时,我遇到一个问题:当我向应用程序发送请求时,它对我没有任何响应,而且总是在等待。 当我发现问题时,我发现在我的服务器机器(linux)中有许多关闭等待。 我不知道怎么解决这个问题,有人能帮我吗? 下面是我使用tornado的代码:
#coding=utf-8
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer`enter code here`
from tornado.ioloop import IOLoop
from service import app #app is a flask in another file:app=Flask(__name__)
from config import SERVER_CONF
from appLog import logging
def startService():
logging.info('start web,http://%s:%s/test'%(SERVER_CONF['IP'],SERVER_CONF['PORT']))
try:
http_server=HTTPServer(WSGIContainer(app))
http_server.listen(SERVER_CONF['PORT'],address=SERVER_CONF['IP'])
IOLoop.instance().start()
except Exception as e:
logging.error('start failed:')
logging.error(e)
if __name__=='__main__':
startService()
{1}我的理解中描述了{1}。在
{我强烈推荐一种更好的方法来对付龙卷风,我强烈建议使用一种更好的方法。如果使用Flask很重要,我建议您探索一种不同的方法来确保并发性(例如,nginx负载平衡器后面有多个实例),甚至可以看看Sanic,它既异步,又与Flask非常相似。在
相关问题 更多 >
编程相关推荐