Browse Source

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

Ask Solem 9 years ago
parent
commit
2fcee73b20

+ 1 - 0
celery/app/base.py

@@ -465,6 +465,7 @@ class Celery(object):
                 timeout=conf.EMAIL_TIMEOUT,
                 use_ssl=conf.EMAIL_USE_SSL,
                 use_tls=conf.EMAIL_USE_TLS,
+                charset=conf.EMAIL_CHARSET,
             )
 
     def select_queues(self, queues=None):

+ 1 - 0
celery/app/defaults.py

@@ -220,6 +220,7 @@ NAMESPACES = {
         'TIMEOUT': Option(2, type='float'),
         'USE_SSL': Option(False, type='bool'),
         'USE_TLS': Option(False, type='bool'),
+        'CHARSET': Option('us-ascii'),
     },
     'SERVER_EMAIL': Option('celery@localhost'),
     'ADMINS': Option((), type='tuple'),

+ 3 - 2
celery/loaders/base.py

@@ -224,10 +224,11 @@ class BaseLoader(object):
     def mail_admins(self, subject, body, fail_silently=False,
                     sender=None, to=None, host=None, port=None,
                     user=None, password=None, timeout=None,
-                    use_ssl=False, use_tls=False):
+                    use_ssl=False, use_tls=False, charset='us-ascii'):
         message = self.mail.Message(sender=sender, to=to,
                                     subject=safe_str(subject),
-                                    body=safe_str(body))
+                                    body=safe_str(body),
+                                    charset=charset)
         mailer = self.mail.Mailer(host=host, port=port,
                                   user=user, password=password,
                                   timeout=timeout, use_ssl=use_ssl,

+ 7 - 0
celery/tests/worker/test_consumer.py

@@ -115,6 +115,13 @@ class test_Consumer(AppCase):
             c.start()
             sleep.assert_called_with(1)
 
+    def test_no_retry_raises_error(self):
+        self.app.conf.BROKER_CONNECTION_RETRY = False
+        c = self.get_consumer()
+        c.blueprint.start.side_effect = socket.error()
+        with self.assertRaises(socket.error):
+            c.start()
+
     def _closer(self, c):
         def se(*args, **kwargs):
             c.blueprint.state = CLOSE

+ 4 - 0
celery/worker/consumer.py

@@ -277,6 +277,10 @@ class Consumer(object):
             try:
                 blueprint.start(self)
             except self.connection_errors as exc:
+                # If we're not retrying connections, no need to catch
+                # connection errors
+                if not self.app.conf.BROKER_CONNECTION_RETRY:
+                    raise
                 if isinstance(exc, OSError) and exc.errno == errno.EMFILE:
                     raise  # Too many open files
                 maybe_shutdown()

+ 9 - 0
docs/configuration.rst

@@ -1633,6 +1633,15 @@ to the SMTP server when sending emails.
 
 The default is 2 seconds.
 
+EMAIL_CHARSET
+~~~~~~~~~~~~~
+.. versionadded:: 3.2.0
+
+Charset for outgoing emails. Default is "us-ascii".
+
+.. setting:: EMAIL_CHARSET
+
+
 .. _conf-example-error-mail-config:
 
 Example E-Mail configuration

+ 1 - 1
docs/django/first-steps-with-django.rst

@@ -136,7 +136,7 @@ concrete app instance:
 Using the Django ORM/Cache as a result backend.
 -----------------------------------------------
 
-The ``django-celery`` library defines result backends that
+The [``django-celery``](https://github.com/celery/django-celery) library defines result backends that
 uses the Django ORM and Django Cache frameworks.
 
 To use this with your project you need to follow these four steps:

+ 1 - 1
docs/getting-started/introduction.rst

@@ -39,7 +39,7 @@ What do I need?
 .. sidebar:: Version Requirements
     :subtitle: Celery version 3.0 runs on
 
-    - Python ❨2.5, 2.6, 2.7, 3.2, 3.3❩
+    - Python ❨2.5, 2.6, 2.7, 3.2, 3.3, 3.4
     - PyPy ❨1.8, 1.9❩
     - Jython ❨2.5, 2.7❩.
 

+ 3 - 0
extra/supervisord/celery.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+source {{ additional variables }}
+exec celery --app={{ application_name }}.celery:app worker --loglevel=INFO -n worker.%%h

+ 5 - 0
extra/supervisord/celeryd.conf

@@ -6,6 +6,11 @@
 ; Set full path to celery program if using virtualenv
 command=celery worker -A proj --loglevel=INFO
 
+; Alternatively,
+;command=celery --app=your_app.celery:app worker --loglevel=INFO -n worker.%%h
+; Or run a script
+;command=celery.sh
+
 directory=/path/to/project
 user=nobody
 numprocs=1