#5751·celery

Celery.send_task with option "exchange" is ignored by the code if not used with other options

Author: allan-simonCreated Sep 24, 2019Updated Sep 27, 2026
LabelsIssue Type: Bug ReportStatus: Needs Verification ✘

Checklist

  • I have checked the issues list for similar or identical bug reports.
  • I have checked the pull requests list for existing proposed fixes.
  • I have checked the commit log to find out if the bug was already fixed in the master branch.
  • I have included all related issues and possible duplicate issues in this issue (If there are none, check this box anyway).

Related Issues and Possible Duplicates

Related Issues

  • None

Possible Duplicates

  • None

Description

When doing this code :

 celery = Celery(broker="amqp://guest:[email protected]:5672/")                                                                                                                                                                                                           
 celery.send_task(                                                                                                                                                                                                                            
     "robot.worker",                                                                                                                                                                                                                
     kwargs={},                                                                                                                                                                                                                               
     exchange="I_am_useless", # with  exchange=Exchange("I_am_useless") I got the same results                                                                                                                                                                                                          
 )  

the exchange named is ignored, and instead an empty string is sent as the exchange name, the documentation regarding send_task redirect for the apply_async and if we look here

https://docs.celeryproject.org/en/latest/reference/celery.app.task.html#celery.app.task.Task.apply_async

it only says that we could put a string or Exchange object , but alone, none have any effect.

on https://stackoverflow.com/questions/58079129/celery-it-ignores-the-exchange-name-when-sending-a-task somebody pointed out the incrimimated code, that show why there's this behaviour

Suggestions

we should either precise in the documentation (and maybe put a warning in the code, or even worse introduce a breaking change by not permitting the use alone, as it's clearly not working as the developer expects and it's against the python zen ?) that the argument exchange can not be used alone, or we should change the code so that if used alone, it defaults to exchange of type "direct" (which seems to be the current behavior anyway for other cases where there's no exchange_type precised)