Open acheraime opened 5 years ago
are you relying on setdefault
to set the value of EVENT_CONSUMER_APP_CONFIG
?
if so you might need to move that line before the from event_consumer
import
that did not fix it.
can you share a working celery.py example?
have you tried actually setting the env var in your environment, rather than rely on setdefault
to update os.environ
dict?
how do you know it's "not working"?
are you starting your worker with -A celery:consumer_app
?
I did all that still no success. I know because celery log does not show any message related to my consumer. All my other celery tasks work.
When I move the os.environ line before "from event_consumer import ..." I got below error
File "/usr/share/virtualenvs/connect/local/lib/python2.7/site-packages/flexisettings/__init__.py", line 61, in __init__
config = _load_config(initial_namespace, defaults)
File "/usr/share/virtualenvs/connect/local/lib/python2.7/site-packages/flexisettings/__init__.py", line 111, in _load_config
_temp.update_from_object(app_config, lambda key: key.startswith(namespace))
File "/usr/share/virtualenvs/connect/local/lib/python2.7/site-packages/configloader/__init__.py", line 66, in update_from_object
mod = __import__(path, globals(), locals(), [name], 0)
TypeError: Item in ``from list'' not a string
@acheraime this seems important
whatever value you have set for EVENT_CONSUMER_APP_CONFIG
it seems like that file can't be imported
I had a similar problem yesterday.
You need to set the environment variables first.
os.environ.setdefault('EVENT_CONSUMER_APP_CONFIG', str('xxx.csm_settings'))
os.environ.setdefault('EVENT_CONSUMER_CONFIG_NAMESPACE', str('EVENT_CONSUMER'))
Then perform the import.
from event_consumer.handlers import AMQPRetryConsumerStep
consumer_app.config_from_object('django.conf:settings')
consumer_app.steps['consumer'].add(AMQPRetryConsumerStep)
Problem solved.
I've followed all the instructions but the consumer handler will not work, all the configuration are being ignored. See below celery.py and consumer configuration files.
celery.py
config file