Celery (Django + Redis) task fails: "No connection could be made because the target machine actively refused it" -
update: decided try using django broker simplicity, assumed did wrong in redis setup. however, after making changes described in docs same error below when attempting run celery task .delay()
. celery worker starts , shows it's connected django transport. firewall issue?
original
i'm working on django project , attempting add background tasks. i've installed celery , chosen redis broker, , installed (i'm on windows machine, fyi). celery worker starts, connects redis server, , discovers shared_tasks
-------------- celery@galactica v3.1.19 (cipater) ---- **** ----- --- * *** * -- windows-7-6.1.7601-sp1 -- * - **** --- - ** ---------- [config] - ** ---------- .> app: proj:0x2dbf970 - ** ---------- .> transport: redis://localhost:6379/0 - ** ---------- .> results: disabled - *** --- * --- .> concurrency: 8 (prefork) -- ******* ---- --- ***** ----- [queues] -------------- .> celery exchange=celery(direct) key=celery [tasks] . app.tasks.add . app.tasks.mul . app.tasks.xsum . proj.celery.debug_task [2016-01-16 11:53:05,586: info/mainprocess] connected redis://localhost:6379/ 0 [2016-01-16 11:53:06,611: info/mainprocess] mingle: searching neighbors [2016-01-16 11:53:09,628: info/mainprocess] mingle: alone c:\python34\lib\site-packages\celery\fixups\django.py:265: userwarning: using se ttings.debug leads memory leak, never use setting in production enviro nments! warnings.warn('using settings.debug leads memory leak, never ' [2016-01-16 11:53:14,670: warning/mainprocess] c:\python34\lib\site-packages\cel ery\fixups\django.py:265: userwarning: using settings.debug leads memory le ak, never use setting in production environments! warnings.warn('using settings.debug leads memory leak, never ' [2016-01-16 11:53:14,671: warning/mainprocess] celery@galactica ready.
i'm following intro docs tasks simple, including 1 called add
. can run tasks in python shell, when attempt call add.delay()
have celery handle it, appears connection isn't successful:
>>> add.delay(2,2) traceback (most recent call last): file "c:\python34\lib\site-packages\kombu\utils\__init__.py", line 423, in __call__ return self.__value__ attributeerror: 'channelpromise' object has no attribute '__value__' during handling of above exception, exception occurred: traceback (most recent call last): file "c:\python34\lib\site-packages\kombu\connection.py", line 436, in _ensured return fun(*args, **kwargs) file "c:\python34\lib\site-packages\kombu\messaging.py", line 177, in _publish channel = self.channel file "c:\python34\lib\site-packages\kombu\messaging.py", line 194, in _get_channel channel = self._channel = channel() file "c:\python34\lib\site-packages\kombu\utils\__init__.py", line 425, in __call__ value = self.__value__ = self.__contract__() file "c:\python34\lib\site-packages\kombu\messaging.py", line 209, in <lambda> channel = channelpromise(lambda: connection.default_channel) file "c:\python34\lib\site-packages\kombu\connection.py", line 756, in default_channel self.connection file "c:\python34\lib\site-packages\kombu\connection.py", line 741, in connection self._connection = self._establish_connection() file "c:\python34\lib\site-packages\kombu\connection.py", line 696, in _establish_connection conn = self.transport.establish_connection() file "c:\python34\lib\site-packages\kombu\transport\pyamqp.py", line 116, in establish_connection conn = self.connection(**opts) file "c:\python34\lib\site-packages\amqp\connection.py", line 165, in __init__ self.transport = self.transport(host, connect_timeout, ssl) file "c:\python34\lib\site-packages\amqp\connection.py", line 186, in transport return create_transport(host, connect_timeout, ssl) file "c:\python34\lib\site-packages\amqp\transport.py", line 299, in create_transport return tcptransport(host, connect_timeout) file "c:\python34\lib\site-packages\amqp\transport.py", line 95, in __init__ raise socket.error(last_err) oserror: [winerror 10061] no connection made because target machine actively refused during handling of above exception, exception occurred: traceback (most recent call last): file "<stdin>", line 1, in <module> file "c:\python34\lib\site-packages\celery\app\task.py", line 453, in delay return self.apply_async(args, kwargs) file "c:\python34\lib\site-packages\celery\app\task.py", line 560, in apply_async **dict(self._get_exec_options(), **options) file "c:\python34\lib\site-packages\celery\app\base.py", line 354, in send_task reply_to=reply_to or self.oid, **options file "c:\python34\lib\site-packages\celery\app\amqp.py", line 305, in publish_task **kwargs file "c:\python34\lib\site-packages\kombu\messaging.py", line 172, in publish routing_key, mandatory, immediate, exchange, declare) file "c:\python34\lib\site-packages\kombu\connection.py", line 457, in _ensured interval_max) file "c:\python34\lib\site-packages\kombu\connection.py", line 369, in ensure_connection interval_start, interval_step, interval_max, callback) file "c:\python34\lib\site-packages\kombu\utils\__init__.py", line 246, in retry_over_time return fun(*args, **kwargs) file "c:\python34\lib\site-packages\kombu\connection.py", line 237, in connect return self.connection file "c:\python34\lib\site-packages\kombu\connection.py", line 741, in connection self._connection = self._establish_connection() file "c:\python34\lib\site-packages\kombu\connection.py", line 696, in _establish_connection conn = self.transport.establish_connection() file "c:\python34\lib\site-packages\kombu\transport\pyamqp.py", line 116, in establish_connection conn = self.connection(**opts) file "c:\python34\lib\site-packages\amqp\connection.py", line 165, in __init__ self.transport = self.transport(host, connect_timeout, ssl) file "c:\python34\lib\site-packages\amqp\connection.py", line 186, in transport return create_transport(host, connect_timeout, ssl) file "c:\python34\lib\site-packages\amqp\transport.py", line 299, in create_transport return tcptransport(host, connect_timeout) file "c:\python34\lib\site-packages\amqp\transport.py", line 95, in __init__ raise socket.error(last_err) oserror: [winerror 10061] no connection made because target machine actively refused
there's no output on console celery worker running, don't think ever gets task. believe settings.py, celery.py , tasks.py alright:
settings.py
#celery settings broker_url = 'redis://localhost:6379/0'
celery.py
from __future__ import absolute_import import os celery import celery # set default django settings module 'celery' program. os.environ.setdefault('django_settings_module', 'proj.settings') django.conf import settings # noqa app = celery('proj') # using string here means worker not have # pickle object when using windows. app.config_from_object('django.conf:settings') app.autodiscover_tasks(lambda: settings.installed_apps) @app.task(bind=true) def debug_task(self): print('request: {0!r}'.format(self.request))
tasks.py
from __future__ import absolute_import #from proj.celery import app celery import shared_task @shared_task def add(x, y): return x + y @shared_task def mul(x, y): return x * y @shared_task def xsum(numbers): return sum(numbers)
my project layout identical celery example django project layout on github, example here. looks like:
proj ├── proj │ ├── celery.py │ ├── __init__.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py ├── manage.py └── app ├── __init__.py ├── models.py ├── tasks.py ├── tests.py └── views.py
apologies on other app in project being named 'app' - makes things bit confusing read, , result of autogenerating base project in visual studio ptvs installed. have changed on, didn't realize name vague.
thanks thoughts- i've been stumped while.
i got around this, i'm not sure how. came exact configuration next day, , tasks making celery worker.
perhaps 1 of services restarted key, i'm not sure.
if else runs this, on windows: make sure redis-server active , see incoming connections ping task. had done before posting question, seems candidate being misconfigured.
Comments
Post a Comment