From 10c9b6de6f054eb0739431482b33dc5ce81ddb53 Mon Sep 17 00:00:00 2001 From: "wangwenyan@fangjia.com" Date: Wed, 4 Apr 2018 13:34:59 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E6=8D=95=E8=8E=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PriceSystem/CalcCmdReceiver.py | 3 +-- PriceSystem/config/__init__.py | 4 ++++ PriceSystem/fangjia/__init__.py | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/PriceSystem/CalcCmdReceiver.py b/PriceSystem/CalcCmdReceiver.py index 59761c9..89fb4e9 100644 --- a/PriceSystem/CalcCmdReceiver.py +++ b/PriceSystem/CalcCmdReceiver.py @@ -32,7 +32,7 @@ def worker(): sell_price.calc_sell_price(cmd) end_time = time.time() logger.info("Calc SUC:" + str(cmd) + "\t计算成功,耗时:" + str(end_time - start_time)) - except Exception as ex: + except BaseException as ex: print(ex) logger.exception(ex) end_time = time.time() @@ -53,7 +53,6 @@ if __name__ == "__main__": if os.path.exists(lock_file): os.remove(lock_file) pro_num = config.get_worker_num() - #pro_num = 1 pool = multiprocessing.Pool(processes=pro_num) for pid in range(0, pro_num): pool.apply_async(worker, ()) diff --git a/PriceSystem/config/__init__.py b/PriceSystem/config/__init__.py index 29331ed..adae809 100644 --- a/PriceSystem/config/__init__.py +++ b/PriceSystem/config/__init__.py @@ -1,4 +1,8 @@ def get_worker_num(): + """ + 获取进行均价计算的进程数 + :return: + """ return 20 diff --git a/PriceSystem/fangjia/__init__.py b/PriceSystem/fangjia/__init__.py index 697768d..1d3d27e 100644 --- a/PriceSystem/fangjia/__init__.py +++ b/PriceSystem/fangjia/__init__.py @@ -25,7 +25,7 @@ def get_logger(name): file_handler = logging.FileHandler("/home/goojia/logs/" + name + ".log") file_handler.setFormatter(formatter) logger.addHandler(file_handler) - logger.setLevel("INFO") + logger.setLevel("ERROR") return logger @@ -39,7 +39,7 @@ def get_performance_logger(name): file_handler = logging.FileHandler("/home/goojia/logs/" + name + ".performance.log") file_handler.setFormatter(formatter) logger.addHandler(file_handler) - logger.setLevel("INFO") + logger.setLevel("ERROR") return logger now = datetime.datetime.now().replace(hour=0, minute=0, second=0, microsecond=0) From 0067e12701a0c6d4be9ef154c8b9dba079e1dd27 Mon Sep 17 00:00:00 2001 From: "wangwenyan@fangjia.com" Date: Wed, 4 Apr 2018 13:39:53 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PriceSystem/CalcCmdReceiver.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/PriceSystem/CalcCmdReceiver.py b/PriceSystem/CalcCmdReceiver.py index 89fb4e9..0e068a7 100644 --- a/PriceSystem/CalcCmdReceiver.py +++ b/PriceSystem/CalcCmdReceiver.py @@ -21,7 +21,6 @@ def worker(): cmd = client.lpop(QUEUE) except Exception as ex: cmd = None - print(ex) if cmd is None: time.sleep(60) logger.info("等待接受计算命令") @@ -33,10 +32,9 @@ def worker(): end_time = time.time() logger.info("Calc SUC:" + str(cmd) + "\t计算成功,耗时:" + str(end_time - start_time)) except BaseException as ex: - print(ex) logger.exception(ex) end_time = time.time() - logger.error("Calc ERROR :" + str(cmd) + "\t计算失败,耗时:" + (end_time - start_time)) + logger.error("Calc ERROR :" + str(cmd) + "\t计算失败,耗时:" + str(end_time - start_time)) def format_cmd(cmd): From 70b645a6c9da5dff1d930aeaabb5aeaedaa4d798 Mon Sep 17 00:00:00 2001 From: "wangwenyan@fangjia.com" Date: Wed, 4 Apr 2018 13:43:54 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PriceSystem/CalcCmdReceiver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PriceSystem/CalcCmdReceiver.py b/PriceSystem/CalcCmdReceiver.py index 0e068a7..0a39af5 100644 --- a/PriceSystem/CalcCmdReceiver.py +++ b/PriceSystem/CalcCmdReceiver.py @@ -32,7 +32,7 @@ def worker(): end_time = time.time() logger.info("Calc SUC:" + str(cmd) + "\t计算成功,耗时:" + str(end_time - start_time)) except BaseException as ex: - logger.exception(ex) + logger.error(str(ex)) end_time = time.time() logger.error("Calc ERROR :" + str(cmd) + "\t计算失败,耗时:" + str(end_time - start_time)) From 1f9d64e130ee38072ee96ca099ac7c8c31d4880a Mon Sep 17 00:00:00 2001 From: "wangwenyan@fangjia.com" Date: Wed, 4 Apr 2018 13:46:11 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=81=A2=E5=A4=8D=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PriceSystem/CalcCmdReceiver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PriceSystem/CalcCmdReceiver.py b/PriceSystem/CalcCmdReceiver.py index 0a39af5..0e068a7 100644 --- a/PriceSystem/CalcCmdReceiver.py +++ b/PriceSystem/CalcCmdReceiver.py @@ -32,7 +32,7 @@ def worker(): end_time = time.time() logger.info("Calc SUC:" + str(cmd) + "\t计算成功,耗时:" + str(end_time - start_time)) except BaseException as ex: - logger.error(str(ex)) + logger.exception(ex) end_time = time.time() logger.error("Calc ERROR :" + str(cmd) + "\t计算失败,耗时:" + str(end_time - start_time))