mirror of
https://github.com/jazzband/django-celery-monitor.git
synced 2026-03-16 22:00:24 +00:00
Minor docstring updates.
This commit is contained in:
parent
4ae8a39a32
commit
72d895d93b
2 changed files with 4 additions and 2 deletions
|
|
@ -71,7 +71,6 @@ class Camera(Polaroid):
|
|||
|
||||
def handle_worker(self, hostname_worker):
|
||||
hostname, worker = hostname_worker
|
||||
# was there an update in the last n seconds?
|
||||
return self.WorkerState.objects.update_heartbeat(
|
||||
hostname,
|
||||
heartbeat=self.get_heartbeat(worker),
|
||||
|
|
|
|||
|
|
@ -50,14 +50,17 @@ class WorkerStateQuerySet(ExtendedQuerySet):
|
|||
|
||||
def update_heartbeat(self, hostname, heartbeat, update_freq):
|
||||
with transaction.atomic():
|
||||
# check if there was an update in the last n seconds?
|
||||
interval = Now() - timedelta(seconds=update_freq)
|
||||
recent_worker_updates = self.filter(
|
||||
hostname=hostname,
|
||||
last_update__gte=interval,
|
||||
)
|
||||
if recent_worker_updates.exists():
|
||||
obj = recent_worker_updates.latest()
|
||||
# if yes, get the latest update and move on
|
||||
obj = recent_worker_updates.get()
|
||||
else:
|
||||
# if no, update the worker state and move on
|
||||
obj, _ = self.select_for_update_or_create(
|
||||
hostname=hostname,
|
||||
defaults={'last_heartbeat': heartbeat},
|
||||
|
|
|
|||
Loading…
Reference in a new issue