Merge branch 'master' of http://192.168.0.27/dev0/PriceSystem
This commit is contained in:
@@ -21,7 +21,6 @@ def worker():
|
|||||||
cmd = client.lpop(QUEUE)
|
cmd = client.lpop(QUEUE)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
cmd = None
|
cmd = None
|
||||||
print(ex)
|
|
||||||
if cmd is None:
|
if cmd is None:
|
||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
logger.info("等待接受计算命令")
|
logger.info("等待接受计算命令")
|
||||||
@@ -32,11 +31,10 @@ def worker():
|
|||||||
sell_price.calc_sell_price(cmd)
|
sell_price.calc_sell_price(cmd)
|
||||||
end_time = time.time()
|
end_time = time.time()
|
||||||
logger.info("Calc SUC:" + str(cmd) + "\t计算成功,耗时:" + str(end_time - start_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)
|
logger.exception(ex)
|
||||||
end_time = time.time()
|
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):
|
def format_cmd(cmd):
|
||||||
@@ -53,7 +51,6 @@ if __name__ == "__main__":
|
|||||||
if os.path.exists(lock_file):
|
if os.path.exists(lock_file):
|
||||||
os.remove(lock_file)
|
os.remove(lock_file)
|
||||||
pro_num = config.get_worker_num()
|
pro_num = config.get_worker_num()
|
||||||
#pro_num = 1
|
|
||||||
pool = multiprocessing.Pool(processes=pro_num)
|
pool = multiprocessing.Pool(processes=pro_num)
|
||||||
for pid in range(0, pro_num):
|
for pid in range(0, pro_num):
|
||||||
pool.apply_async(worker, ())
|
pool.apply_async(worker, ())
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
def get_worker_num():
|
def get_worker_num():
|
||||||
|
"""
|
||||||
|
获取进行均价计算的进程数
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
return 20
|
return 20
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user