use both pid and cluster_id

This commit is contained in:
Jason McVetta
2020-02-12 18:23:47 +07:00
parent d22c916bfc
commit 14a602ee8b
4 changed files with 13 additions and 10 deletions
+6 -5
View File
@@ -8,11 +8,12 @@ from django_q.signing import SignedPackage, BadSignature
class Status(object):
"""Cluster status base class."""
def __init__(self, pid):
def __init__(self, pid, cluster_id):
self.workers = []
self.tob = None
self.reincarnations = 0
self.cluster_id = pid
self.pid = pid
self.cluster_id = cluster_id
self.sentinel = 0
self.status = Conf.STOPPED
self.done_q_size = 0
@@ -27,7 +28,7 @@ class Stat(Status):
"""Status object for Cluster monitoring."""
def __init__(self, sentinel):
super(Stat, self).__init__(sentinel.parent_pid or sentinel.pid)
super(Stat, self).__init__(sentinel.parent_pid or sentinel.pid, cluster_id=sentinel.cluster_id)
self.broker = sentinel.broker or get_broker()
self.tob = sentinel.tob
self.reincarnations = sentinel.reincarnations
@@ -72,7 +73,7 @@ class Stat(Status):
return self.done_q_size + self.task_q_size == 0
@staticmethod
def get(cluster_id, broker=None):
def get(pid, cluster_id, broker=None):
"""
gets the current status for the cluster
:param cluster_id: id of the cluster
@@ -86,7 +87,7 @@ class Stat(Status):
return SignedPackage.loads(pack)
except BadSignature:
return None
return Status(cluster_id)
return Status(pid=pid, cluster_id=cluster_id)
@staticmethod
def get_all(broker=None):