Quellcode durchsuchen

Merge branch 'master' of github.com:celery/celery

Mher Movsisyan vor 12 Jahren
Ursprung
Commit
dc68ab3fbd

+ 2 - 1
CONTRIBUTORS.txt

@@ -111,4 +111,5 @@ Matt Long, 2012/07/04
 David Markey, 2012/07/05
 Jared Biel, 2012/07/05
 Jed Smith, 2012/07/08
-Łukasz Langa, 2012/07/10
+Łukasz Langa, 2012/07/10
+Rinat Shigapov, 2012/07/20

+ 4 - 0
celery/bin/base.py

@@ -168,6 +168,7 @@ class Command(object):
         pool_option = self.with_pool_option(argv)
         if pool_option:
             self.maybe_patch_concurrency(argv, *pool_option)
+        self.on_concurrency_setup()
 
         # Dump version and exit if '--version' arg set.
         self.early_version(argv)
@@ -196,6 +197,9 @@ class Command(object):
             # set up eventlet/gevent environments ASAP.
             concurrency.get_implementation(pool)
 
+    def on_concurrency_setup(self):
+        pass
+
     def usage(self, command):
         """Returns the command-line usage string for this app."""
         return '%%prog [options] %s' % (self.args, )

+ 4 - 3
celery/bin/celery.py

@@ -68,7 +68,7 @@ def command(fun, name=None, sortpri=0):
     return fun
 
 
-def get_extension_commands(namespace='celery.commands'):
+def load_extension_commands(namespace='celery.commands'):
     try:
         from pkg_resources import iter_entry_points
     except ImportError:
@@ -83,8 +83,6 @@ def get_extension_commands(namespace='celery.commands'):
             warnings.warn('Cannot load extension %r: %r' % (sym, exc))
         else:
             command(cls, name=ep.name)
-get_extension_commands()
-
 
 class Command(BaseCommand):
     help = ''
@@ -917,6 +915,9 @@ class CeleryCommand(BaseCommand):
             # that may have to be loaded as early as possible.
             return (['-P'], ['--pool'])
 
+    def on_concurrency_setup(self):
+        load_extension_commands()
+
 
 def determine_exit_status(ret):
     if isinstance(ret, int):

+ 6 - 0
celery/concurrency/threads.py

@@ -8,10 +8,16 @@
 """
 from __future__ import absolute_import
 
+import os
+
 from celery.utils.compat import UserDict
 
 from .base import apply_target, BasePool
 
+#: Makes sure we don't use threading.local for stacks
+#: since apparently they don't work properly.
+os.environ['USE_PURE_LOCALS'] = '1'
+
 
 class NullDict(UserDict):
 

+ 1 - 1
celery/task/trace.py

@@ -110,7 +110,7 @@ class TraceInfo(object):
     def handle_failure(self, task, store_errors=True):
         """Handle exception."""
         req = task.request
-        _, type_, tb = sys.exc_info()
+        type_, _, tb = sys.exc_info()
         try:
             exc = self.retval
             einfo = ExceptionInfo((type_, get_pickleable_exception(exc), tb))

+ 1 - 1
celery/tests/security/test_certificate.py

@@ -26,7 +26,7 @@ class test_Certificate(SecurityCase):
         self.assertRaises(SecurityError, Certificate, KEY1)
 
     def test_has_expired(self):
-        self.assertFalse(Certificate(CERT1).has_expired())
+        self.assertTrue(Certificate(CERT1).has_expired())
 
 
 class test_CertStore(SecurityCase):

+ 2 - 1
celery/utils/threads.py

@@ -20,6 +20,7 @@ _Event = threading._Event
 
 active_count = (getattr(threading, 'active_count', None) or
                 threading.activeCount)
+USE_PURE_LOCALS = os.environ.get("USE_PURE_LOCALS")
 
 
 class Event(_Event):
@@ -92,7 +93,7 @@ class bgThread(Thread):
         if self.is_alive():
             self.join(1e100)
 
-if detect_environment() == 'default':
+if detect_environment() == 'default' and not USE_PURE_LOCALS:
     class LocalStack(threading.local):
 
         def __init__(self):

+ 2 - 2
docs/tutorials/daemonizing.rst

@@ -103,7 +103,7 @@ This is an example configuration for those using `django-celery`::
     CELERYD_GROUP="celery"
 
     # Name of the projects settings module.
-    export DJANGO_SETTINGS_MODULE="settings"
+    export DJANGO_SETTINGS_MODULE="MyProject.settings"
 
 .. _generic-initd-celeryd-django-with-env-example:
 
@@ -145,7 +145,7 @@ environment's python interpreter::
     CELERYD_GROUP="celery"
 
     # Name of the projects settings module.
-    export DJANGO_SETTINGS_MODULE="settings"
+    export DJANGO_SETTINGS_MODULE="MyProject.settings"
 
 .. _generic-initd-celeryd-options:
 

+ 4 - 6
extra/centos/celeryd.init

@@ -13,7 +13,7 @@
 # ============================================
 #
 # :Usage: /etc/init.d/${basename $0} {start|stop|restart|status}
-# :Configuration file: /etc/default/celeryd
+# :Configuration file: /etc/sysconfig/celeryd
 #
 # To implement separate init scripts, do NOT copy this script.  Instead,
 # symlink it.  I.e., if my new application, "little-worker" needs an init, I
@@ -21,9 +21,7 @@
 #
 #   ln -s /etc/init.d/celeryd /etc/init.d/little-worker
 #
-# You can then configure this by manipulating /etc/sysconfig/little-worker.  It
-# will still read defaults from /etc/defaults/celeryd, but everything can be
-# overriden by sysconfig.
+# You can then configure this by manipulating /etc/sysconfig/little-worker.
 #
 
 # Setting `prog` here allows you to symlink this init script, making it easy
@@ -77,7 +75,7 @@ start_workers () {
                                --logfile=$CELERYD_LOG_FILE \
                                --loglevel=$CELERYD_LOG_LEVEL \
                                --cmd="$CELERYD" \
-			                   --quiet \
+                                --quiet \
                                $CELERYD_OPTS
     RETVAL=$?
 
@@ -96,7 +94,7 @@ stop_workers () {
     # If we haven't ended, explicitly kill it!
     if [ ! -f $CELERYD_PID_FILE ] || [ ! -e /proc/$(cat $CELERYD_PID_FILE) ]; then
         failure
-	echo
+    echo
         return
     fi
 

+ 1 - 1
extra/debian/init.d-deprecated/celerybeat

@@ -33,7 +33,7 @@
 #   CELERYD_CHDIR="/opt/Project/"
 #
 #   # Name of the projects settings module.
-#   export DJANGO_SETTINGS_MODULE="settings"
+#   export DJANGO_SETTINGS_MODULE="MyProject.settings"
 #
 #   # Path to celeryd
 #   CELERYD="/opt/Project/manage.py celeryd"

+ 1 - 1
extra/debian/init.d-deprecated/celeryd

@@ -32,7 +32,7 @@
 #   CELERYD_CHDIR="/opt/Project/"
 #
 #   # Name of the projects settings module.
-#   export DJANGO_SETTINGS_MODULE="settings"
+#   export DJANGO_SETTINGS_MODULE="MyProject.settings"
 #
 #   # Path to celeryd
 #   CELERYD="/opt/Project/manage.py"

+ 1 - 1
extra/debian/init.d-deprecated/celeryevcam

@@ -35,7 +35,7 @@
 #   CELERYD_CHDIR="/opt/Project/"
 #
 #   # Name of the projects settings module.
-#   export DJANGO_SETTINGS_MODULE="settings"
+#   export DJANGO_SETTINGS_MODULE="MyProject.settings"
 #
 #   # Path to celeryd
 #   CELERYEV="/opt/Project/manage.py"

+ 1 - 1
extra/generic-init.d/celeryevcam

@@ -35,7 +35,7 @@
 #   CELERYD_CHDIR="/opt/Project/"
 #
 #   # Name of the projects settings module.
-#   export DJANGO_SETTINGS_MODULE="settings"
+#   export DJANGO_SETTINGS_MODULE="MyProject.settings"
 #
 #   # Path to celeryd
 #   CELERYEV="/opt/Project/manage.py"