mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-08 01:48:11 +08:00
use both pid and cluster_id
This commit is contained in:
+6
-5
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user