Repository navigation
Closed as not planned
Labels
Description
Hi I am using airflow 1.10.12 with celery executor with SQS. When configuring predefined_queues in celery as mentioned here I am getting the bellow error:
[2020-10-01 17:37:54,498: CRITICAL/MainProcess] Unrecoverable error: AttributeError("'str' object has no attribute 'items'")
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/kombu/transport/virtual/base.py", line 921, in create_channel
return self._avail_channels.pop()
IndexError: pop from empty list
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/celery/worker/worker.py", line 208, in start
self.blueprint.start(self)
File "/usr/local/lib/python3.7/site-packages/celery/bootsteps.py", line 119, in start
step.start(parent)
File "/usr/local/lib/python3.7/site-packages/celery/bootsteps.py", line 369, in start
return self.obj.start()
File "/usr/local/lib/python3.7/site-packages/celery/worker/consumer/consumer.py", line 318, in start
blueprint.start(self)
File "/usr/local/lib/python3.7/site-packages/celery/bootsteps.py", line 119, in start
step.start(parent)
File "/usr/local/lib/python3.7/site-packages/celery/worker/consumer/connection.py", line 23, in start
c.connection = c.connect()
File "/usr/local/lib/python3.7/site-packages/celery/worker/consumer/consumer.py", line 405, in connect
conn = self.connection_for_read(heartbeat=self.amqheartbeat)
File "/usr/local/lib/python3.7/site-packages/celery/worker/consumer/consumer.py", line 412, in connection_for_read
self.app.connection_for_read(heartbeat=heartbeat))
File "/usr/local/lib/python3.7/site-packages/celery/worker/consumer/consumer.py", line 439, in ensure_connected
callback=maybe_shutdown,
File "/usr/local/lib/python3.7/site-packages/kombu/connection.py", line 389, in ensure_connection
self._ensure_connection(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/kombu/connection.py", line 445, in _ensure_connection
callback, timeout=timeout
File "/usr/local/lib/python3.7/site-packages/kombu/utils/functional.py", line 344, in retry_over_time
return fun(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/kombu/connection.py", line 874, in _connection_factory
self._connection = self._establish_connection()
File "/usr/local/lib/python3.7/site-packages/kombu/connection.py", line 809, in _establish_connection
conn = self.transport.establish_connection()
File "/usr/local/lib/python3.7/site-packages/kombu/transport/virtual/base.py", line 941, in establish_connection
self._avail_channels.append(self.create_channel(self))
File "/usr/local/lib/python3.7/site-packages/kombu/transport/virtual/base.py", line 923, in create_channel
channel = self.Channel(connection)
File "/usr/local/lib/python3.7/site-packages/kombu/transport/SQS.py", line 134, in __init__
self._update_queue_cache(self.queue_name_prefix)
File "/usr/local/lib/python3.7/site-packages/kombu/transport/SQS.py", line 140, in _update_queue_cache
for queue_name, q in self.predefined_queues.items():
AttributeError: 'str' object has no attribute 'items'
airflow.cfg:
[celery_broker_transport_options]
'predefined_queues': = { 'my-q': {
'url': 'https://ap-southeast-2.queue.amazonaws.com/123456/my-q',
'access_key_id': 'xxx',
'secret_access_key': 'xxx',
}
}
Activity
mik-laj commentedon Oct 1, 2020
This section only accepts strings as values. You need to use "celery_config_options" to set-up other types. See:
airflow/airflow/executors/celery_executor.py
Lines 66 to 69 in 3ca11eb
[-]celery executer with SQS[/-][+]celery executer with SQS and predefined_queues[/+]sudarshan2906 commentedon Oct 1, 2020
Thanks. I am using my celery configuration file for now.
But do you think we can add
predefined_queuesin DEFAULT_CELERY_CONFIG . That whenpredefined_queuesis passed in celery config it will convert it to json. Its quite a important config for celery when using sqs as queue.mik-laj commentedon Oct 5, 2020
I have no experience with SQS, but it sounds like a good solution.
sudarshan2906 commentedon Oct 5, 2020
well
predefined_queuesis supported in celery version5.0.0. But airflow doesn't supports that version. I can't find any ticket created for that. Will this be upgraded in airflow2.0.0?mik-laj commentedon Oct 5, 2020
@auvipy can you share some details about Celery 5? What is the status of? Should we think about migration? why is it worth migrating?
chris-french commentedon Oct 6, 2020
@sudarshan2906 @mik-laj -- did you find a solution for this?
It seems like you would need to make a small change to
setup.pyto install sqs support for celery in Airflow:source: https://docs.celeryproject.org/en/4.4.2/getting-started/brokers/sqs.html?highlight=sqs
sudarshan2906 commentedon Oct 6, 2020
@chris-french Yup, I got it working using celery version to be 4.4.2. But the predefined_queues property was not supported by airflow as its a dict format. I used a celery_config file and changed the celery_config location in
airflow.cfgcelery_config.py
charliegriefer commentedon Aug 19, 2021
@sudarshan2906 - can you show the
celery_config_optionsline in yourairflow.cfg? I'm doing something similar, but getting an error on the scheduler saying:My
celery_configis in my AIRFLOW_HOME, and currently it's pretty basic:EDIT to add, an exception higher up in the stack trace:
[2021-08-19 09:19:06,303] {configuration.py:468} ERROR - No module named 'celery_config', so it's just not finding the file.The specific line in my airflow.cfg:
celery_config_options = celery_config.MY_CELERY_CONFIGThanks!
nicnguyen3103 commentedon Dec 20, 2021
For anyone who is still struggling with the import path of celery config here is how to import it:
AIRFLOW__CELERY__CELERY_CONFIG_OPTIONS=airflow.celery_default_config.CELERY_CONFIGto import your new configAirflow now should pick up your new celery config and apply it to the worker
auvipy commentedon Dec 20, 2021
can anyone check this if it is helpful celery/kombu#1450 ?
github-actions commentedon Jul 9, 2023
This issue has been automatically marked as stale because it has been open for 365 days without any activity. There has been several Airflow releases since last activity on this issue. Kindly asking to recheck the report against latest Airflow version and let us know if the issue is reproducible. The issue will be closed in next 30 days if no further activity occurs from the issue author.
github-actions commentedon Aug 8, 2023
This issue has been closed because it has not received response from the issue author.
nagaran1 commentedon Nov 30, 2023
The custom celery config file should be kept under PYTHONPATH. Here are the built-in PYTHONPATH.
I have faced similar issue, but after placing the custom config file in ({AIRFLOW_HOME}/config) it worked fine. More details here