29 lines
694 B
Python
29 lines
694 B
Python
import json
|
|
import multiprocessing
|
|
import time
|
|
import redis
|
|
import config
|
|
|
|
QUEUE = "calc_cmd"
|
|
redis_pool = redis.ConnectionPool(host=config.get_redis_host(), port=6379, db=config.get_redis_host())
|
|
|
|
|
|
def monitor(pname):
|
|
client = redis.Redis(connection_pool=redis_pool)
|
|
while True:
|
|
pre_counter = client.llen(QUEUE)
|
|
time.sleep(60)
|
|
print(pname + "#####################################:".zfill(100) + str(
|
|
pre_counter - client.llen(QUEUE)) + "/min")
|
|
|
|
|
|
def format_cmd(cmd):
|
|
return json.loads(cmd)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
pool = multiprocessing.Pool(processes=1)
|
|
pool.apply_async(monitor, ("Monitor-001",))
|
|
pool.close()
|
|
pool.join()
|