I have a Django + Celery setup working correctly in production with RabbitMQ.
AFAIK, it should be sufficient to set CELERY_ALWAYS_EAGER to True in django settings locally, to avoid setting up RabbitMQ for development. I have done this but when calling .delay() on a task I get:
Traceback (most recent call last):
File "lib/python2.7/site-packages/django/core/handlers/base.py", line 132, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "lib/python2.7/site-packages/django/views/generic/base.py", line 71, in view
return self.dispatch(request, *args, **kwargs)
File "lib/python2.7/site-packages/django/views/generic/base.py", line 89, in dispatch
return handler(request, *args, **kwargs)
File "lib/python2.7/site-packages/django/views/generic/edit.py", line 215, in post
return self.form_valid(form)
File "app/web/views.py", line 188, in form_valid
form.send_email()
File "app/web/forms.py", line 17, in send_email
send_email.delay(mail, recipients, 'Contact %s' % name, comment)
File "lib/python2.7/site-packages/celery/app/task.py", line 453, in delay
return self.apply_async(args, kwargs)
File "lib/python2.7/site-packages/celery/app/task.py", line 559, in apply_async
**dict(self._get_exec_options(), **options)
File "lib/python2.7/site-packages/celery/app/base.py", line 353, in send_task
reply_to=reply_to or self.oid, **options
File "lib/python2.7/site-packages/celery/app/amqp.py", line 305, in publish_task
**kwargs
File "lib/python2.7/site-packages/kombu/messaging.py", line 172, in publish
routing_key, mandatory, immediate, exchange, declare)
File "lib/python2.7/site-packages/kombu/connection.py", line 457, in _ensured
interval_max)
File "lib/python2.7/site-packages/kombu/connection.py", line 369, in ensure_connection
interval_start, interval_step, interval_max, callback)
File "lib/python2.7/site-packages/kombu/utils/__init__.py", line 243, in retry_over_time
return fun(*args, **kwargs)
File "lib/python2.7/site-packages/kombu/connection.py", line 237, in connect
return self.connection
File "lib/python2.7/site-packages/kombu/connection.py", line 741, in connection
self._connection = self._establish_connection()
File "lib/python2.7/site-packages/kombu/connection.py", line 696, in _establish_connection
conn = self.transport.establish_connection()
File "lib/python2.7/site-packages/kombu/transport/librabbitmq.py", line 123, in establish_connection
conn = self.Connection(**opts)
File "lib/python2.7/site-packages/librabbitmq/__init__.py", line 199, in __init__
self.connect()
ConnectionError: Error opening socket: a socket error occurred
For the record, since celery 4.0 this setting has been renamed to task_always_eager:
# setting renamed on celery 4.0
CELERY_ALWAYS_EAGER --> task_always_eager
To help the migration to this version, Celery provides the following util to update automatically your settings:
# --django allows to keep uppercase settings and CELERY_ prefix
$ celery upgrade settings proj/settings.py --django
So I have found the problem. Basically I was missing:
from .celery import app as celery_app
in proj/proj/__init__.py
For some misterious reason this seems to fail only when running runserver and not when running wsgi.py via uWSGI. Not sure why, but with the import it works on runserver too.
Related
I am currently going through 'The Definitive Guide to Celery and Django' course by testdriven.io. I've managed to containerize the whole application. Everything was built correctly and seemed to work just fine, but when I tried to enter the Django shell and run a task, to ensure everything works correctly, the following error appeared.
>>> divide.delay(1, 2)
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/kombu/utils/functional.py", line 30, in __call__
return self.__value__
AttributeError: 'ChannelPromise' object has no attribute '__value__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 446, in _reraise_as_library_errors
yield
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 433, in _ensure_connection
return retry_over_time(
File "/usr/local/lib/python3.10/site-packages/kombu/utils/functional.py", line 312, in retry_over_time
return fun(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 877, in _connection_factory
self._connection = self._establish_connection()
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 812, in _establish_connection
conn = self.transport.establish_connection()
File "/usr/local/lib/python3.10/site-packages/kombu/transport/pyamqp.py", line 201, in establish_connection
conn.connect()
File "/usr/local/lib/python3.10/site-packages/amqp/connection.py", line 323, in connect
self.transport.connect()
File "/usr/local/lib/python3.10/site-packages/amqp/transport.py", line 129, in connect
self._connect(self.host, self.port, self.connect_timeout)
File "/usr/local/lib/python3.10/site-packages/amqp/transport.py", line 184, in _connect
self.sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python3.10/site-packages/celery/app/task.py", line 425, in delay
return self.apply_async(args, kwargs)
File "/usr/local/lib/python3.10/site-packages/celery/app/task.py", line 575, in apply_async
return app.send_task(
File "/usr/local/lib/python3.10/site-packages/celery/app/base.py", line 788, in send_task
amqp.send_task_message(P, name, message, **options)
File "/usr/local/lib/python3.10/site-packages/celery/app/amqp.py", line 510, in send_task_message
ret = producer.publish(
File "/usr/local/lib/python3.10/site-packages/kombu/messaging.py", line 177, in publish
return _publish(
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 523, in _ensured
return fun(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/kombu/messaging.py", line 186, in _publish
channel = self.channel
File "/usr/local/lib/python3.10/site-packages/kombu/messaging.py", line 209, in _get_channel
channel = self._channel = channel()
File "/usr/local/lib/python3.10/site-packages/kombu/utils/functional.py", line 32, in __call__
value = self.__value__ = self.__contract__()
File "/usr/local/lib/python3.10/site-packages/kombu/messaging.py", line 225, in <lambda>
channel = ChannelPromise(lambda: connection.default_channel)
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 895, in default_channel
self._ensure_connection(**conn_opts)
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 432, in _ensure_connection
with ctx():
File "/usr/local/lib/python3.10/contextlib.py", line 153, in __exit__
self.gen.throw(typ, value, traceback)
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 450, in _reraise_as_library_errors
raise ConnectionError(str(exc)) from exc
kombu.exceptions.OperationalError: [Errno 111] Connection refused
I've done a quick research and in most cases it seemed to be a lack of the following lines
from config.celery import app as celery_app
__all__ = ['celery_app']
in the config.__init__.py, but it's clearly not an issue here.
I also double checked whether redis container is up and listening on port 6379.
The only difference between my code and the course code is that I decided to use Poetry package manager instead of requirements.txt file and pip.
At this point I am a little bit confused I'll be thankful for any tip. You can find the whole code below:
https://github.com/Kibraks/django-celery-app
well i have same view same setting for celery in another app, when i launch another one, he is work, absolutely work, but when i launch this, nothing, i installed everthyng like in another one, but nothing, pls help me!
if you have some ideas how to fix please let me know)
This is full traceback
Traceback (most recent call last):
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\kombu\utils\__init__.py", line 423, in __call__
return self.__value__
AttributeError: 'ChannelPromise' object has no attribute '__value__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\kombu\connection.py", line 449, in _ensured
return fun(*args, **kwargs)
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\kombu\messaging.py", line 177, in _publish
channel = self.channel
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\kombu\messaging.py", line 194, in _get_channel
channel = self._channel = channel()
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\kombu\utils\__init__.py", line 425, in __call__
value = self.__value__ = self.__contract__()
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\kombu\messaging.py", line 209, in <lambda>
channel = ChannelPromise(lambda: connection.default_channel)
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\kombu\connection.py", line 771, in default_channel
self.connection
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\kombu\connection.py", line 756, in connection
self._connection = self._establish_connection()
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\kombu\connection.py", line 711, in _establish_connection
conn = self.transport.establish_connection()
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\kombu\transport\pyamqp.py", line 116, in establish_connection
conn = self.Connection(**opts)
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\amqp\connection.py", line 165, in __init__
self.transport = self.Transport(host, connect_timeout, ssl)
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\amqp\connection.py", line 186, in Transport
return create_transport(host, connect_timeout, ssl)
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\amqp\transport.py", line 299, in create_transport
return TCPTransport(host, connect_timeout)
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\amqp\transport.py", line 95, in __init__
raise socket.error(last_err)
OSError: [WinError 10061]The connection is not established, because the destination computer rejected the connection request
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\django\core\handlers\exception.py", line 41, in inner
response = get_response(request)
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\django\core\handlers\base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\django\core\handlers\base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\django\utils\decorators.py", line 149, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\src\accounts\decorators.py", line 25, in _wrapped_view
return view_func(request, *args, **kwargs)
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\src\accounts\views.py", line 41, in signup
register_task.delay(username, password, email, get_secret_key)
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\celery\app\task.py", line 453, in delay
return self.apply_async(args, kwargs)
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\celery\app\task.py", line 559, in apply_async
**dict(self._get_exec_options(), **options)
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\celery\app\base.py", line 353, in send_task
reply_to=reply_to or self.oid, **options
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\celery\app\amqp.py", line 305, in publish_task
**kwargs
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\kombu\messaging.py", line 172, in publish
routing_key, mandatory, immediate, exchange, declare)
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\kombu\connection.py", line 470, in _ensured
interval_max)
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\kombu\connection.py", line 382, in ensure_connection
interval_start, interval_step, interval_max, callback)
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\kombu\utils\__init__.py", line 246, in retry_over_time
return fun(*args, **kwargs)
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\kombu\connection.py", line 250, in connect
return self.connection
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\kombu\connection.py", line 756, in connection
self._connection = self._establish_connection()
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\kombu\connection.py", line 711, in _establish_connection
conn = self.transport.establish_connection()
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\kombu\transport\pyamqp.py", line 116, in establish_connection
conn = self.Connection(**opts)
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\amqp\connection.py", line 165, in __init__
self.transport = self.Transport(host, connect_timeout, ssl)
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\amqp\connection.py", line 186, in Transport
return create_transport(host, connect_timeout, ssl)
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\amqp\transport.py", line 299, in create_transport
return TCPTransport(host, connect_timeout)
File "C:\Users\P.A.N.D.E.M.I.C\Desktop\shop\lib\site-packages\amqp\transport.py", line 95, in __init__
raise socket.error(last_err)
OSError: [WinError 10061] `The connection is not established, because the destination computer rejected the connection request`
this is celery
from __future__ import absolute_import
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'src.settings')
from django.conf import settings
from celery import Celery
app = Celery('src')
# This reads, e.g., CELERY_ACCEPT_CONTENT = ['json'] from settings.py:
app.config_from_object('django.conf:settings')
# For autodiscover_tasks to work, you must define your tasks in a file called 'tasks.py'.
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
#app.task(bind=True)
def debug_task(self):
print("Request: {0!r}".format(self.request))
this is settings
# CELERY STUFF
BROKER_URL = 'redis://127.0.0.1:6379'
CELERY_RESULT_BACKEND = 'redis://127.0.0.1:6379'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TIMEZONE = TIME_ZONE
this is view
#csrf_protect
#check_recaptcha
def signup(request):
if request.method == 'POST':
form = RegistrationForm(request.POST)
print(form)
if form.is_valid() and request.recaptcha_is_valid:
print(form.cleaned_data)
email = form.cleaned_data['email']
username = form.cleaned_data['username']
password = form.cleaned_data['password1']
get_secret_key = activation_key_generator(username)
link = "127.0.0.1:8000/accounts/activate/{0}".format(get_secret_key)
html_message = '<h3>Your username: <b>{0}</b> <br> <b>Your password: <b>{1}</b></h3><br><h1>That to get full access to our services, go through link below!</h1> <br> Activate need raw link? <br> {2}'.format(username, password, link)
register_task.delay(username, password, email, get_secret_key)
send_some_email_task.delay(email, username, html_message)
return redirect('/accounts/register/verification')
form = RegistrationForm(request.POST or None)
context = {'form':form}
return render(request, 'accounts/registration/signup.html', context)
You said in the comments you are using Redis but the configuration you have is for RabbitMQ. Check Using Redis page for more info on configuration. More specifically, your broker URL should be something like redis://:password#hostname:port/db_number, not amqp.
I have an API app running Django. I have 2 containers,
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5620d232e96c django_worker:v1 "/bin/bash" 4 days ago Up 4 days drunk_goldberg
eeb5b0e8dbce django_main:v1 "./main.sh" 4 days ago Up 4 days 0.0.0.0:8000->8000/tcp sick_almeida
Both host the same code base. The main is exposing the API, The other is running the celery worker via the command,
su -m celery -c "celery --app=XXX.celery:app worker -Q ${QUEUE} --loglevel=INFO --autoscale=10,3"
The Django settings file in both containers is,
BROKER_URL = 'redis://10.1.1.8:6379/0'
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
However in the main container i get the error,
ERROR:XXX.views:Exception Raised:
Traceback (most recent call last):
File "/opt/XXX/XXX/views.py", line 169, in upgrade
ABC.delay(username,password,ip,device,manifest,peer_ip)
File "/usr/local/lib/python2.7/dist-packages/celery/app/task.py", line 453, in delay
return self.apply_async(args, kwargs)
File "/usr/local/lib/python2.7/dist-packages/celery/app/task.py", line 560, in apply_async
**dict(self._get_exec_options(), **options)
File "/usr/local/lib/python2.7/dist-packages/celery/app/base.py", line 354, in send_task
reply_to=reply_to or self.oid, **options
File "/usr/local/lib/python2.7/dist-packages/celery/app/amqp.py", line 305, in publish_task
**kwargs
File "/usr/local/lib/python2.7/dist-packages/kombu/messaging.py", line 172, in publish
routing_key, mandatory, immediate, exchange, declare)
File "/usr/local/lib/python2.7/dist-packages/kombu/connection.py", line 457, in _ensured
interval_max)
File "/usr/local/lib/python2.7/dist-packages/kombu/connection.py", line 369, in ensure_connection
interval_start, interval_step, interval_max, callback)
File "/usr/local/lib/python2.7/dist-packages/kombu/utils/__init__.py", line 243, in retry_over_time
return fun(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/kombu/connection.py", line 237, in connect
return self.connection
File "/usr/local/lib/python2.7/dist-packages/kombu/connection.py", line 741, in connection
self._connection = self._establish_connection()
File "/usr/local/lib/python2.7/dist-packages/kombu/connection.py", line 696, in _establish_connection
conn = self.transport.establish_connection()
File "/usr/local/lib/python2.7/dist-packages/kombu/transport/pyamqp.py", line 116, in establish_connection
conn = self.Connection(**opts)
File "/usr/local/lib/python2.7/dist-packages/amqp/connection.py", line 165, in __init__
self.transport = self.Transport(host, connect_timeout, ssl)
File "/usr/local/lib/python2.7/dist-packages/amqp/connection.py", line 186, in Transport
return create_transport(host, connect_timeout, ssl)
File "/usr/local/lib/python2.7/dist-packages/amqp/transport.py", line 299, in create_transport
return TCPTransport(host, connect_timeout)
File "/usr/local/lib/python2.7/dist-packages/amqp/transport.py", line 95, in __init__
raise socket.error(last_err)
error: [Errno 111] Connection refused
Now if I test the connection from the main container its fine.
Any ideas ?
I know the title is a little ambiguous and I'd only ever ask here if it wasn't a last resort - but I am stuck. I've pulled down a Django project from my work repo that is rather ancient (we're talking 1.13), and I've been tasked with bringing it into 1.9. Okay, fair enough.
I've loaded the database from a MySQL dump and faked the migrations just fine. However, when I run the server, I get hit with this:
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 256, in __init__
(code, msg) = self.connect(host, port)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 316, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 291, in _get_socket
return socket.create_connection((host, port), timeout)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 575, in create_connection
raise err
error: [Errno 60] Operation timed out
At first, I had no idea what was going on here, but from the look of it, SMTP is throwing this exception - probably due to the mailing server not being accessible. Any how, I can't even get print statements to show up in settings.py, and so have no idea where to even start to trace this problem through.
Any guidance would be lovely.
EDIT: Here is the new error:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "/Users/krisvukasinovic/.virtualenvs/give2gether/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 63, in __call__
return self.application(environ, start_response)
File "/Users/krisvukasinovic/.virtualenvs/give2gether/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 177, in __call__
response = self.get_response(request)
File "/Users/krisvukasinovic/.virtualenvs/give2gether/lib/python2.7/site-packages/django/core/handlers/base.py", line 230, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/Users/krisvukasinovic/.virtualenvs/give2gether/lib/python2.7/site-packages/django/core/handlers/base.py", line 284, in handle_uncaught_exception
'request': request
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 1191, in error
self._log(ERROR, msg, args, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 1284, in _log
self.handle(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 1294, in handle
self.callHandlers(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 1334, in callHandlers
hdlr.handle(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 757, in handle
self.emit(record)
File "/Users/krisvukasinovic/.virtualenvs/give2gether/lib/python2.7/site-packages/django/utils/log.py", line 117, in emit
self.send_mail(subject, message, fail_silently=True, html_message=html_message)
File "/Users/krisvukasinovic/.virtualenvs/give2gether/lib/python2.7/site-packages/django/utils/log.py", line 120, in send_mail
mail.mail_admins(subject, message, *args, connection=self.connection(), **kwargs)
File "/Users/krisvukasinovic/.virtualenvs/give2gether/lib/python2.7/site-packages/django/core/mail/__init__.py", line 97, in mail_admins
mail.send(fail_silently=fail_silently)
File "/Users/krisvukasinovic/.virtualenvs/give2gether/lib/python2.7/site-packages/django/core/mail/message.py", line 292, in send
return self.get_connection(fail_silently).send_messages([self])
File "/Users/krisvukasinovic/.virtualenvs/give2gether/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages
new_conn_created = self.open()
File "/Users/krisvukasinovic/.virtualenvs/give2gether/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 58, in open
self.connection = connection_class(self.host, self.port, **connection_params)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 256, in __init__
(code, msg) = self.connect(host, port)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 316, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 291, in _get_socket
return socket.create_connection((host, port), timeout)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 575, in create_connection
raise err
error: [Errno 61] Connection refused
As you know, the error you were getting is because your logger was set up to send emails whenever you received an error. The problem being that your development environment doesn't have access to the mail server that this logger relies on.
What happens is django then raises this new error and the actual error gets hidden away.
The actual solution to this is to create a separate settings.py file for development, that way you don't need to worry about the mail server not being there, nor (I expect) would you really care.
When running runserver you can then specify this settings file with
runserver --settings=mysettings
For completeness, heres a very simple development settings.py file
from myapp.settings import *
print 'DEV'
DEBUG = True
# INSTALLED_APPS += ['debug_toolbar']
# MIDDLEWARE_CLASSES += ['debug_toolbar.middleware.DebugToolbarMiddleware']
i upgraded my celery from 2.4.X to celery-2.5.2, then modified the Broker_URL to be
BROKER_TRANSPORT = "sqlalchemy"
BROKER_URL = "sqla+mysql://root:root#localhost:3306/db"
this config can be referred via the page of http://docs.celeryproject.org/en/latest/getting-started/brokers/sqlalchemy.html#broker-sqlalchemy
the Celery process can be started successfully, but whan i call .delay or apply_async the process will throw out exception KeyError: 'No such transport: mysql'
i have no idea about this.. looks like everything should be right.
Traceback
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Python27\lib\site-packages\celery-2.5.2-py2.7.egg\celery\app\task\__init__.py", line 353, in delay
return self.apply_async(args, kwargs)
File "C:\Python27\lib\site-packages\celery-2.5.2-py2.7.egg\celery\app\task\__init__.py", line 449, in apply_async
publish = publisher or self.app.amqp.publisher_pool.acquire(block=True)
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\connection.py", line 625, in acquire
R = self.prepare(R)
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\pools.py", line 55, in prepare
p = p()
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\pools.py", line 46, in <lambda>
return lambda: self.create_producer()
File "C:\Python27\lib\site-packages\celery-2.5.2-py2.7.egg\celery\app\amqp.py", line 265, in create_producer
pub = self.app.amqp.TaskPublisher(conn, auto_declare=False)
File "C:\Python27\lib\site-packages\celery-2.5.2-py2.7.egg\celery\app\amqp.py", line 328, in TaskPublisher
return TaskPublisher(*args, **self.app.merge(defaults, kwargs))
File "C:\Python27\lib\site-packages\celery-2.5.2-py2.7.egg\celery\app\amqp.py", line 158, in __init__
super(TaskPublisher, self).__init__(*args, **kwargs)
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\compat.py", line 61, in __init__
super(Publisher, self).__init__(connection, self.exchange, **kwargs)
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\messaging.py", line 69, in __init__
channel = channel.default_channel
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\connection.py", line 556, in default_channel
self.connection
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\connection.py", line 549, in connection
self._connection = self._establish_connection()
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\connection.py", line 509, in _establish_connection
conn = self.transport.establish_connection()
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\connection.py", line 569, in transport
self._transport = self.create_transport()
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\connection.py", line 324, in create_transport
return self.get_transport_cls()(client=self)
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\connection.py", line 331, in get_transport_cls
transport_cls = get_transport_cls(transport_cls)
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\transport__init__.py", line 94, in get_transport_cls
_transport_cache[transport] = _get_transport_cls(transport)
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\transport\__init__.py", line 75, in _get_transport_cls
transport_module_name, transport_cls_name = resolve_transport(transport)
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\transport\__init__.py", line 70, in resolve_transport
raise KeyError("No such transport: %s" % (transport, ))
KeyError: 'No such transport: mysql'
After some debugging I've tracked this down to the version of kombu being installed. Kombu 2.1.5 was released on April 13th and does not appear to be compatible. I was able to resolve this issue by explicitly degrading to version 2.1.3.