Commit 0c491807 by 柴鹏飞

接口默认返回100。修改接口线程池为1,不然数据库连接会断

parent b2f7c64e
...@@ -18,7 +18,7 @@ recommender = UserCFRecommender(top_n=5, k=5) ...@@ -18,7 +18,7 @@ recommender = UserCFRecommender(top_n=5, k=5)
class RecommendHandler(tornado.web.RequestHandler): class RecommendHandler(tornado.web.RequestHandler):
executor = ThreadPoolExecutor(2) executor = ThreadPoolExecutor(1)
@tornado.gen.coroutine @tornado.gen.coroutine
def get(self): def get(self):
...@@ -26,12 +26,12 @@ class RecommendHandler(tornado.web.RequestHandler): ...@@ -26,12 +26,12 @@ class RecommendHandler(tornado.web.RequestHandler):
if uid is None: if uid is None:
logger.warn('请求参数不正确,无uid') logger.warn('请求参数不正确,无uid')
size = self.get_argument('size', 10) size = self.get_argument('size', 100)
try: try:
size = int(size) size = int(size)
except Exception as e: except Exception as e:
logger.warn('size=%s 不是数字', size) logger.warn('size=%s 不是数字', size)
size = 10 size = 100
ret = yield self.run(uid, size) ret = yield self.run(uid, size)
self.write(ret) self.write(ret)
...@@ -41,7 +41,7 @@ class RecommendHandler(tornado.web.RequestHandler): ...@@ -41,7 +41,7 @@ class RecommendHandler(tornado.web.RequestHandler):
def post(self): def post(self):
param = json.loads(self.request.body.decode('utf-8')) param = json.loads(self.request.body.decode('utf-8'))
uid = param.get('uid', None) uid = param.get('uid', None)
size = param.get('size', 10) size = param.get('size', 100)
if uid is None: if uid is None:
logger.warn('请求参数不正确,无uid') logger.warn('请求参数不正确,无uid')
...@@ -50,7 +50,7 @@ class RecommendHandler(tornado.web.RequestHandler): ...@@ -50,7 +50,7 @@ class RecommendHandler(tornado.web.RequestHandler):
@run_on_executor @run_on_executor
def run(self, uid, size=10): def run(self, uid, size=100):
logger.info('request@@uid=%s@@size=%s', uid, size) logger.info('request@@uid=%s@@size=%s', uid, size)
try: try:
recommend_result = recommender.recommend(uid, size=size, is_merge=True) recommend_result = recommender.recommend(uid, size=size, is_merge=True)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment