Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
DEKHTIARJonathan committed Apr 5, 2018
1 parent 3a42dd2 commit f8b1268
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions django_celery_monitor/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from celery.utils.time import maybe_timedelta
from django.db import models, router, transaction

from .utils import Now
#from .utils import Now
from django.utils import timezone


class ExtendedQuerySet(models.QuerySet):
Expand Down Expand Up @@ -47,7 +48,8 @@ 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)
#interval = Now() - timedelta(seconds=update_freq)
interval = timezone.now() - timedelta(seconds=update_freq)
recent_worker_updates = self.filter(
hostname=hostname,
last_update__gte=interval,
Expand All @@ -74,8 +76,9 @@ def active(self):
def expired(self, states, expires):
"""Return all expired task states."""
return self.filter(
state__in=states,
tstamp__lte=Now() - maybe_timedelta(expires),
state__in = states,
#tstamp__lte = Now() - maybe_timedelta(expires),
tstamp__lte = timezone.now() - maybe_timedelta(expires),
)

def expire_by_states(self, states, expires):
Expand Down

0 comments on commit f8b1268

Please sign in to comment.