Tornado will get stuck after running for a while without any error message,can not response to any request,the requested information like below is also not displayed, it looks like the request is not received, has anyone encountered this situation?
[2022-09-18 10:10:55 web.py:log_request:2243 INFO] 200 GET /address/area
my database connection code:
engine = create_engine(
url, pool_size=0, pool_pre_ping=True, pool_recycle=300, pool_use_lifo=True, echo_pool=True, max_overflow=-1)
def get_session():
session_factory = sessionmaker(bind=engine)
Session = scoped_session(session_factory)
session = Session()
return session
my base handler:
class BaseHandler(tornado.web.RequestHandle):
def prepare(self):
self.session = get_session()
def on_finish(self):
self.session.close()
my service.py:
import logging
import tornado.ioloop
import tornado.web
from routes.route import routes
import os
from handlers.base import DetectStaticFileHandler, ErrorHandler
import tornado.locale
import tornado.log
import tornado.options
class LogFormatter(tornado.log.LogFormatter):
def __init__(self):
super(LogFormatter, self).__init__(
fmt='%(color)s[%(asctime)s %(filename)s:%(funcName)s:%(lineno)d %(levelname)s]%(end_color)s %(message)s',
datefmt='%Y-%m-%d %H:%M:%S'
)
def run(i, port):
i18n_path = os.path.join(os.path.dirname(__file__), 'locales')
tornado.locale.load_translations(i18n_path)
tornado.locale.set_default_locale('en_US')
current_path = os.path.dirname(__file__)
static_path = os.path.join(current_path, 'static')
tornado.options.parse_command_line()
[i.setFormatter(LogFormatter()) for i in logging.getLogger().handlers]
settings = {
"static_path": static_path,
"debug": True,
"static_handler_class": DetectStaticFileHandler,
"default_handler_class": ErrorHandler,
"max_buffer_size": 104857600
}
app = tornado.web.Application(routes, **settings)
app.listen(port, "127.0.0.1", xheaders=True)
print('Tornado app running,i:%s,port:%s' % (i, port))
tornado.ioloop.IOLoop.current().start()
if __name__ == "__main__":
run(0,7920)