From 1f464dd93237bcdc5e77d5a1adff6624ce1d6f14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=B9=B2?= Date: Fri, 9 Mar 2018 16:03:49 +0800 Subject: [PATCH] Merge branch 'master' of 192.168.0.27:dev0/PriceSystem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改: PriceSystem/CalcCmdReceiver.py 修改: PriceSystem/CalcCmdSender.py 修改: PriceSystem/CalcSpeedMonitor.py 修改: PriceSystem/config/__init__.py 修改: PriceSystem/sell_price/zhuge0118A.py 修改: PriceSystem/test.py --- PriceSystem/CalcCmdReceiver.py | 14 +++++++++++++- PriceSystem/CalcCmdSender.py | 2 +- PriceSystem/CalcSpeedMonitor.py | 3 +-- PriceSystem/config/__init__.py | 2 +- PriceSystem/sell_price/zhuge0118A.py | 16 ++++++++-------- PriceSystem/test.py | 2 +- 6 files changed, 25 insertions(+), 14 deletions(-) diff --git a/PriceSystem/CalcCmdReceiver.py b/PriceSystem/CalcCmdReceiver.py index b9bdce7..ab0d3b7 100644 --- a/PriceSystem/CalcCmdReceiver.py +++ b/PriceSystem/CalcCmdReceiver.py @@ -7,6 +7,7 @@ import sell_price import fangjia import datetime import pytz +import os QUEUE = "calc_cmd" redis_pool = redis.ConnectionPool(host=config.get_redis_host(), port=6379, db=config.get_redis_db()) @@ -46,11 +47,22 @@ def format_cmd(cmd): if __name__ == "__main__": - + user_home = os.path.expanduser('~') + lock_file = user_home + "/price.sys.stop" + if os.path.exists(lock_file): + os.remove(lock_file) pro_num = config.get_worker_num() pool = multiprocessing.Pool(processes=pro_num) for pid in range(0, pro_num): pool.apply_async(worker, ()) pool.close() logger.info("均价系统启动成功") + while True: + if os.path.exists(lock_file): + pool.terminate() + break + else: + time.sleep(3) + if os.path.exists(lock_file): + os.remove(lock_file) pool.join() diff --git a/PriceSystem/CalcCmdSender.py b/PriceSystem/CalcCmdSender.py index 9302d7e..972ef16 100644 --- a/PriceSystem/CalcCmdSender.py +++ b/PriceSystem/CalcCmdSender.py @@ -23,7 +23,7 @@ client = redis.Redis(connection_pool=redisPool) def get_district(): seaweeds = [] keys = {"city": 1, "region": 1, "name": 1, "_id": 0} - for dis in fangjia.get_collection("fangjia", "seaweed").find({"cat": "district", "status": 0, "city": "上海"}, keys): + for dis in fangjia.get_collection("fangjia", "seaweed").find({"cat": "district", "status": 0, "city": "合肥"}, keys): dis["weekend"] = datetime.strptime("2018-03-11", "%Y-%m-%d") seaweeds.append(dis) diff --git a/PriceSystem/CalcSpeedMonitor.py b/PriceSystem/CalcSpeedMonitor.py index b610e6a..767d0f3 100644 --- a/PriceSystem/CalcSpeedMonitor.py +++ b/PriceSystem/CalcSpeedMonitor.py @@ -13,8 +13,7 @@ def monitor(pname): while True: pre_counter = client.llen(QUEUE) time.sleep(60) - print(pname + "#####################################:".zfill(100) + str( - pre_counter - client.llen(QUEUE)) + "/min") + print(pname + "#####################################:".zfill(100) + str(pre_counter - client.llen(QUEUE)) + "/min") def format_cmd(cmd): diff --git a/PriceSystem/config/__init__.py b/PriceSystem/config/__init__.py index 8862b15..c9a8af5 100644 --- a/PriceSystem/config/__init__.py +++ b/PriceSystem/config/__init__.py @@ -8,7 +8,7 @@ def get_logging_config(): def get_worker_num(): - return 30 + return 80 def get_redis_host(): diff --git a/PriceSystem/sell_price/zhuge0118A.py b/PriceSystem/sell_price/zhuge0118A.py index c977e83..4dcdedf 100644 --- a/PriceSystem/sell_price/zhuge0118A.py +++ b/PriceSystem/sell_price/zhuge0118A.py @@ -1311,11 +1311,11 @@ def out_put_price(ct, rl, lk, weekend): pt.replace_one( - {"city": ct, "region": rl, "district_name": p[0], "weekend": weekend}, + {"city": ct, "region": rl, "district_name": p[0], "calc_date": weekend}, - {"city": ct, "region": rl, "district_name": p[0], "c_date": c_date, 'status': int(0), - 'remark': 'week', 'category': 'sell', 'weekend': weekend, 'priority': int(0), - 'problem': None, + {"city": ct, "region": rl, "district_name": p[0], "c_date": c_date, 'status': int(102), + 'remark': 'week', 'category': 'sell', "calc_date": weekend, 'priority': int(0), + 'problem': None, "calc_type" : int(0) }, True ) @@ -1336,10 +1336,10 @@ def out_put_price(ct, rl, lk, weekend): else: pt.replace_one( - {"city": ct, "region": rl, "district_name": p[0], "weekend": weekend}, + {"city": ct, "region": rl, "district_name": p[0], "calc_date": weekend}, - {"city": ct, "region": rl, "district_name": p[0], "c_date": c_date, 'status': int(1), - 'remark': 'week', 'category': 'sell', 'weekend': weekend, 'priority': int(0), - 'problem': mm[0], + {"city": ct, "region": rl, "district_name": p[0], "c_date": c_date, 'status': int(3), + 'remark': 'week', 'category': 'sell', "calc_date": weekend, 'priority': int(0), + 'problem': mm[0], "calc_type" : int(0) }, True ) \ No newline at end of file diff --git a/PriceSystem/test.py b/PriceSystem/test.py index 4f3c502..21300f9 100644 --- a/PriceSystem/test.py +++ b/PriceSystem/test.py @@ -8,7 +8,7 @@ s = time.time() #上海嘉定莱茵北郡 ct='上海' rl='嘉定' -lk='莱茵北郡别墅' +lk='莱茵北郡' #上海闵行上海康城 weekend = datetime.datetime.strptime("2018-03-11", "%Y-%m-%d")