Bläddra i källkod

Fixes eta/countdown when ENABLE_UTC=False. Closes #1065

Ask Solem 12 år sedan
förälder
incheckning
db263327fa
2 ändrade filer med 8 tillägg och 5 borttagningar
  1. 2 2
      celery/utils/timer2.py
  2. 6 3
      celery/worker/consumer.py

+ 2 - 2
celery/utils/timer2.py

@@ -71,10 +71,10 @@ class Entry(object):
             return hash(self) == hash(other)
 
 
-def to_timestamp(d):
+def to_timestamp(d, default_timezone=timezone.utc):
     if isinstance(d, datetime):
         if d.tzinfo is None:
-            d = d.replace(tzinfo=timezone.utc)
+            d = d.replace(tzinfo=default_timezone)
         return timedelta_seconds(d - EPOCH)
     return d
 

+ 6 - 3
celery/worker/consumer.py

@@ -295,7 +295,8 @@ class Consumer(object):
         self.app.amqp.queues.select_remove(queue)
         self.task_consumer.cancel_by_queue(queue)
 
-    def on_task(self, task, task_reserved=task_reserved):
+    def on_task(self, task, task_reserved=task_reserved,
+            to_system_tz=timezone.to_system):
         """Handle received task.
 
         If the task has an `eta` we enter it into the ETA schedule,
@@ -317,9 +318,11 @@ class Consumer(object):
                     expires=task.expires and task.expires.isoformat())
 
         if task.eta:
-            eta = timezone.to_system(task.eta) if task.utc else task.eta
             try:
-                eta = to_timestamp(eta)
+                if task.utc:
+                    eta = to_timestamp(to_system_tz(task.eta))
+                else:
+                    eta = to_timestamp(task.eta, timezone.local)
             except OverflowError as exc:
                 error("Couldn't convert eta %s to timestamp: %r. Task: %r",
                       task.eta, exc, task.info(safe=True), exc_info=True)