Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
max-muoto committed May 8, 2023
1 parent 4bcac7a commit b95e6a3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions celery/events/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@

DRIFT_WARNING = (
"Substantial drift from %s may mean clocks are out of sync. Current drift is "
"%s seconds. [orig: %s recv: %s]"
)
"%s seconds. [orig: %s recv: %s]")

logger = get_logger(__name__)
warn = logger.warning
Expand Down Expand Up @@ -199,7 +198,11 @@ def event(type_, timestamp=None,
else:
if not local_received or not timestamp:
return
drift = abs(int(local_received) - int(timestamp))

# To calculate drift, we should compare both timestamps in UTC.
utc_received = datetime.utcfromtimestamp(local_received)
utc_timestamp = datetime.utcfromtimestamp(timestamp)
drift = abs(int(utc_received) - int(utc_timestamp))
if drift > max_drift:
_warn_drift(self.hostname, drift,
local_received, timestamp)
Expand Down

0 comments on commit b95e6a3

Please sign in to comment.