Ask Solem vor 16 Jahren
Ursprung
Commit
e0ade80f31

+ 1 - 1
celery/execute.py

@@ -70,7 +70,7 @@ def apply_async(task, args=None, kwargs=None, routing_key=None,
     delay_task = publisher.delay_task
     delay_task = publisher.delay_task
     if taskset_id:
     if taskset_id:
         delay_task = curry(publisher.delay_task_in_set, taskset_id)
         delay_task = curry(publisher.delay_task_in_set, taskset_id)
-        
+
     task_id = delay_task(task.name, args, kwargs,
     task_id = delay_task(task.name, args, kwargs,
                          routing_key=routing_key, mandatory=mandatory,
                          routing_key=routing_key, mandatory=mandatory,
                          immediate=immediate, priority=priority,
                          immediate=immediate, priority=priority,

+ 1 - 1
celery/messaging.py

@@ -47,7 +47,7 @@ class TaskPublisher(Publisher):
         immediate = kwargs.get("immediate")
         immediate = kwargs.get("immediate")
         mandatory = kwargs.get("mandatory")
         mandatory = kwargs.get("mandatory")
         routing_key = kwargs.get("routing_key")
         routing_key = kwargs.get("routing_key")
-    
+
         task_args = task_args or []
         task_args = task_args or []
         task_kwargs = task_kwargs or {}
         task_kwargs = task_kwargs or {}
         task_id = task_id or str(uuid.uuid4())
         task_id = task_id or str(uuid.uuid4())

+ 6 - 6
celery/monitoring.py

@@ -14,7 +14,7 @@ DEFAULT_CACHE_KEY_PREFIX = "celery-statistics"
 
 
 class Statistics(object):
 class Statistics(object):
     """Base class for classes publishing celery statistics.
     """Base class for classes publishing celery statistics.
-    
+
     .. attribute:: type
     .. attribute:: type
 
 
         **REQUIRED** The type of statistics this class handles.
         **REQUIRED** The type of statistics this class handles.
@@ -97,7 +97,7 @@ class TimerStats(Statistics):
         self.args = args
         self.args = args
         self.kwargs = kwargs
         self.kwargs = kwargs
         self.time_start = time.time()
         self.time_start = time.time()
-    
+
     def on_finish(self):
     def on_finish(self):
         """What to do when the timers :meth:`stop` method is called.
         """What to do when the timers :meth:`stop` method is called.
 
 
@@ -120,7 +120,7 @@ class TaskTimerStats(TimerStats):
 
 
 class StatsCollector(object):
 class StatsCollector(object):
     """Collect and report Celery statistics.
     """Collect and report Celery statistics.
-    
+
     **NOTE**: Please run only one collector at any time, or your stats
     **NOTE**: Please run only one collector at any time, or your stats
         will be skewed.
         will be skewed.
 
 
@@ -142,14 +142,14 @@ class StatsCollector(object):
         instance.
         instance.
 
 
     .. attribute:: total_task_time_running_by_type
     .. attribute:: total_task_time_running_by_type
-        
+
         A dictionary of task names and their total running time in seconds,
         A dictionary of task names and their total running time in seconds,
         counting all the tasks that has been run since the first time
         counting all the tasks that has been run since the first time
         :meth:`collect` was executed on this class instance.
         :meth:`collect` was executed on this class instance.
 
 
     **NOTE**: You have to run :meth:`collect` for these attributes
     **NOTE**: You have to run :meth:`collect` for these attributes
         to be filled.
         to be filled.
-        
+
 
 
     """
     """
 
 
@@ -221,7 +221,7 @@ class StatsCollector(object):
             * Total task processing time.
             * Total task processing time.
 
 
             * Total number of tasks executed
             * Total number of tasks executed
-        
+
         """
         """
         print("Total processing time by task type:")
         print("Total processing time by task type:")
         for task_name, nsecs in self.total_task_time_running_by_type.items():
         for task_name, nsecs in self.total_task_time_running_by_type.items():

+ 1 - 1
celery/pool.py

@@ -81,7 +81,7 @@ class TaskPool(object):
                                         callback=on_return)
                                         callback=on_return)
         if on_acknowledge:
         if on_acknowledge:
             on_acknowledge()
             on_acknowledge()
-        
+
         self._processes[tid] = [result, callbacks, errbacks, meta]
         self._processes[tid] = [result, callbacks, errbacks, meta]
 
 
         return result
         return result

+ 2 - 2
celery/task/base.py

@@ -44,7 +44,7 @@ class Task(object):
         instead.
         instead.
 
 
     .. attribute:: immediate:
     .. attribute:: immediate:
-            
+
         Request immediate delivery. If the message cannot be routed to a
         Request immediate delivery. If the message cannot be routed to a
         task worker immediately, an exception will be raised. This is
         task worker immediately, an exception will be raised. This is
         instead of the default behaviour, where the broker will accept and
         instead of the default behaviour, where the broker will accept and
@@ -52,7 +52,7 @@ class Task(object):
         be consumed.
         be consumed.
 
 
     .. attribute:: priority:
     .. attribute:: priority:
-    
+
         The message priority. A number from ``0`` to ``9``.
         The message priority. A number from ``0`` to ``9``.
 
 
     .. attribute:: ignore_result
     .. attribute:: ignore_result

+ 1 - 1
celery/tests/test_pool.py

@@ -85,7 +85,7 @@ class TestTaskPool(unittest.TestCase):
         self.assertTrue(scratchpad.get(2))
         self.assertTrue(scratchpad.get(2))
         self.assertEquals(scratchpad[2]["ret_value"], 400)
         self.assertEquals(scratchpad[2]["ret_value"], 400)
         self.assertEquals(scratchpad[2]["meta"], {"foo3": "bar3"})
         self.assertEquals(scratchpad[2]["meta"], {"foo3": "bar3"})
-        
+
         res3 = p.apply_async(do_something, args=[30], callbacks=[mycallback],
         res3 = p.apply_async(do_something, args=[30], callbacks=[mycallback],
                             meta={"foo4": "bar4"})
                             meta={"foo4": "bar4"})
 
 

+ 4 - 3
celery/utils.py

@@ -4,16 +4,17 @@ Utility functions
 
 
 """
 """
 
 
+
 def chunks(it, n):
 def chunks(it, n):
     """Split an iterator into chunks with ``n`` elements each.
     """Split an iterator into chunks with ``n`` elements each.
-   
+
     Examples
     Examples
 
 
-        # n == 2 
+        # n == 2
         >>> x = chunks(iter([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), 2)
         >>> x = chunks(iter([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), 2)
         >>> list(x)
         >>> list(x)
         [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10]]
         [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10]]
-       
+
         # n == 3
         # n == 3
         >>> x = chunks(iter([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), 3)
         >>> x = chunks(iter([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), 3)
         >>> list(x)
         >>> list(x)

+ 4 - 4
celery/views.py

@@ -11,17 +11,17 @@ def apply(request, task_name, *args):
     Example:
     Example:
         http://e.com/celery/apply/task_name/arg1/arg2//?kwarg1=a&kwarg2=b
         http://e.com/celery/apply/task_name/arg1/arg2//?kwarg1=a&kwarg2=b
 
 
-    **NOTE** Use with caution, preferably not make this publicly accessible 
+    **NOTE** Use with caution, preferably not make this publicly accessible
     without ensuring your code is safe!
     without ensuring your code is safe!
 
 
     """
     """
     kwargs = request.method == "POST" and \
     kwargs = request.method == "POST" and \
             request.POST.copy() or request.GET.copy()
             request.POST.copy() or request.GET.copy()
-    kwargs = [(k.encode("utf-8"), v)
-                    for k,v in kwargs.items()]
+    kwargs = [(key.encode("utf-8"), value)
+                    for key, value in kwargs.items()]
     if task_name not in tasks:
     if task_name not in tasks:
         raise Http404("apply: no such task")
         raise Http404("apply: no such task")
-        
+
     task = tasks[task_name]
     task = tasks[task_name]
     result = apply_async(task, args=args, kwargs=kwargs)
     result = apply_async(task, args=args, kwargs=kwargs)
     return JSON_dump({"ok": "true", "task_id": result.task_id})
     return JSON_dump({"ok": "true", "task_id": result.task_id})

+ 7 - 7
celery/worker/__init__.py

@@ -23,7 +23,7 @@ class AMQPListener(object):
 
 
     :param bucket_queue: See :attr:`bucket_queue`.
     :param bucket_queue: See :attr:`bucket_queue`.
     :param hold_queue: See :attr:`hold_queue`.
     :param hold_queue: See :attr:`hold_queue`.
-   
+
     .. attribute:: bucket_queue
     .. attribute:: bucket_queue
 
 
         The queue that holds tasks ready for processing immediately.
         The queue that holds tasks ready for processing immediately.
@@ -50,7 +50,7 @@ class AMQPListener(object):
         """Start processing AMQP messages."""
         """Start processing AMQP messages."""
         task_consumer = self.reset_connection()
         task_consumer = self.reset_connection()
         it = task_consumer.iterconsume(limit=None)
         it = task_consumer.iterconsume(limit=None)
-        
+
         while True:
         while True:
             it.next()
             it.next()
 
 
@@ -61,16 +61,16 @@ class AMQPListener(object):
 
 
     def receive_message(self, message_data, message):
     def receive_message(self, message_data, message):
         """The callback called when a new message is received.
         """The callback called when a new message is received.
-        
+
         If the message has an ``eta`` we move it to the hold queue,
         If the message has an ``eta`` we move it to the hold queue,
         otherwise we move it the bucket queue for immediate processing.
         otherwise we move it the bucket queue for immediate processing.
-        
+
         """
         """
         task = TaskWrapper.from_message(message, message_data,
         task = TaskWrapper.from_message(message, message_data,
                                         logger=self.logger)
                                         logger=self.logger)
         eta = message_data.get("eta")
         eta = message_data.get("eta")
         if eta:
         if eta:
-           self.hold_queue.put((task, eta))
+            self.hold_queue.put((task, eta))
         else:
         else:
             self.bucket_queue.put(task)
             self.bucket_queue.put(task)
 
 
@@ -180,10 +180,10 @@ class WorkController(object):
         self.amqp_listener = AMQPListener(self.bucket_queue, self.hold_queue,
         self.amqp_listener = AMQPListener(self.bucket_queue, self.hold_queue,
                                           logger=self.logger)
                                           logger=self.logger)
         self.mediator = Mediator(self.bucket_queue, self.safe_process_task)
         self.mediator = Mediator(self.bucket_queue, self.safe_process_task)
-        
+
         # The order is important here;
         # The order is important here;
         #   the first in the list is the first to start,
         #   the first in the list is the first to start,
-        # and they must be stopped in reverse order.  
+        # and they must be stopped in reverse order.
         self.components = [self.pool,
         self.components = [self.pool,
                            self.mediator,
                            self.mediator,
                            self.periodic_work_controller,
                            self.periodic_work_controller,

+ 2 - 2
celery/worker/controllers.py

@@ -72,9 +72,9 @@ class PeriodicWorkController(threading.Thread):
 
 
     def run(self):
     def run(self):
         """Run the thread.
         """Run the thread.
-        
+
         Should not be used directly, use :meth:`start` instead.
         Should not be used directly, use :meth:`start` instead.
-        
+
         """
         """
         while True:
         while True:
             if self._shutdown.isSet():
             if self._shutdown.isSet():

+ 1 - 1
celery/worker/job.py

@@ -61,7 +61,7 @@ def jail(task_id, task_name, func, args, kwargs):
     """
     """
     ignore_result = getattr(func, "ignore_result", False)
     ignore_result = getattr(func, "ignore_result", False)
     timer_stat = TaskTimerStats.start(task_id, task_name, args, kwargs)
     timer_stat = TaskTimerStats.start(task_id, task_name, args, kwargs)
-        
+
     # See: http://groups.google.com/group/django-users/browse_thread/
     # See: http://groups.google.com/group/django-users/browse_thread/
     #       thread/78200863d0c07c6d/38402e76cf3233e8?hl=en&lnk=gst&
     #       thread/78200863d0c07c6d/38402e76cf3233e8?hl=en&lnk=gst&
     #       q=multiprocessing#38402e76cf3233e8
     #       q=multiprocessing#38402e76cf3233e8