Browse Source

Not all Pool.apply_async arguments changed to using scalar value

Ask Solem 14 years ago
parent
commit
057e1f77ae

+ 1 - 1
celery/concurrency/base.py

@@ -70,7 +70,7 @@ class BasePool(object):
             soft_timeout=None, timeout=None, **compat):
             soft_timeout=None, timeout=None, **compat):
         """Equivalent of the :func:`apply` built-in function.
         """Equivalent of the :func:`apply` built-in function.
 
 
-        All `callbacks` and `errbacks` should complete immediately since
+        Callbacks should optimally return as soon as possible ince
         otherwise the thread which handles the result will get blocked.
         otherwise the thread which handles the result will get blocked.
 
 
         """
         """

+ 1 - 1
celery/contrib/batches.py

@@ -160,7 +160,7 @@ class Batches(Task):
         return self._pool.apply_async(apply_batches_task,
         return self._pool.apply_async(apply_batches_task,
                     (self, args, loglevel, logfile),
                     (self, args, loglevel, logfile),
                     accept_callback=on_accepted,
                     accept_callback=on_accepted,
-                    callbacks=acks_late[True] and [on_return] or [])
+                    callback=acks_late[True] and on_return or None)
 
 
     def debug(self, msg):
     def debug(self, msg):
         self.logger.debug("%s: %s" % (self.name, msg))
         self.logger.debug("%s: %s" % (self.name, msg))

+ 4 - 4
celery/tests/test_concurrency/test_pool.py

@@ -53,9 +53,9 @@ class TestTaskPool(unittest.TestCase):
 
 
         myerrback = mycallback
         myerrback = mycallback
 
 
-        res = p.apply_async(do_something, args=[10], callbacks=[mycallback])
-        res2 = p.apply_async(raise_something, args=[10], errbacks=[myerrback])
-        res3 = p.apply_async(do_something, args=[20], callbacks=[mycallback])
+        res = p.apply_async(do_something, args=[10], callback=mycallback)
+        res2 = p.apply_async(raise_something, args=[10], errback=myerrback)
+        res3 = p.apply_async(do_something, args=[20], callback=mycallback)
 
 
         self.assertEqual(res.get(), 100)
         self.assertEqual(res.get(), 100)
         time.sleep(0.5)
         time.sleep(0.5)
@@ -75,7 +75,7 @@ class TestTaskPool(unittest.TestCase):
         self.assertDictContainsSubset({"ret_value": 400},
         self.assertDictContainsSubset({"ret_value": 400},
                                        scratchpad.get(2))
                                        scratchpad.get(2))
 
 
-        res3 = p.apply_async(do_something, args=[30], callbacks=[mycallback])
+        res3 = p.apply_async(do_something, args=[30], callback=mycallback)
 
 
         self.assertEqual(res3.get(), 900)
         self.assertEqual(res3.get(), 900)
         time.sleep(0.5)
         time.sleep(0.5)

+ 2 - 2
celery/worker/job.py

@@ -363,8 +363,8 @@ class TaskRequest(object):
                                           "request": instance_attrs},
                                           "request": instance_attrs},
                                   accept_callback=self.on_accepted,
                                   accept_callback=self.on_accepted,
                                   timeout_callback=self.on_timeout,
                                   timeout_callback=self.on_timeout,
-                                  callbacks=[self.on_success],
-                                  errbacks=[self.on_failure],
+                                  callback=self.on_success,
+                                  errback=self.on_failure,
                                   soft_timeout=self.task.soft_time_limit,
                                   soft_timeout=self.task.soft_time_limit,
                                   timeout=self.task.time_limit)
                                   timeout=self.task.time_limit)
         return result
         return result