优化代码
This commit is contained in:
@@ -47,8 +47,10 @@ def format_cmd(cmd):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if os.path.exists("/var/run/price/price.sys.stop"):
|
||||
os.remove("/var/run/price/price.sys.stop")
|
||||
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):
|
||||
@@ -56,11 +58,11 @@ if __name__ == "__main__":
|
||||
pool.close()
|
||||
logger.info("均价系统启动成功")
|
||||
while True:
|
||||
if os.path.exists("/var/run/price/price.sys.stop"):
|
||||
if os.path.exists(lock_file):
|
||||
pool.terminate()
|
||||
break
|
||||
else:
|
||||
time.sleep(3)
|
||||
if os.path.exists("/var/run/price/price.sys.stop"):
|
||||
os.remove("/var/run/price/price.sys.stop")
|
||||
if os.path.exists(lock_file):
|
||||
os.remove(lock_file)
|
||||
pool.join()
|
||||
|
||||
Reference in New Issue
Block a user