Open sylvinus opened 9 years ago
How would I get the numbers of workers for a given queue? This seems to work globally, but need per-queue:
def get_num_workers(): return mrq.context.connections.mongodb_jobs.mrq_workers.count({"status": {"$ne": "stop"}})
Here are some code snippets of similar utility functions:
def get_queue_count(queue_name, status_list): return mrq.context.connections.mongodb_jobs.mrq_jobs.count({"status": {"$in": status_list}, "queue": queue_name})
def get_active_count(queue_name): return get_queue_count(queue_name, ["started", "queued"])
def get_num_workers(queue_name): return mrq.context.connections.mongodb_jobs.mrq_workers.count({"status": {"$ne": "stop"}, "config.queues": queue_name})
def get_num_stopped_workers(queue_name): return mrq.context.connections.mongodb_jobs.mrq_workers.count({"status": "stop", "config.queues": queue_name})
As suggested by @mark-99 here: https://github.com/pricingassistant/mrq/issues/98#issuecomment-140488787