<h1 dir="auto">Checklist</h1>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have read the relevant section in the<br>
<a href="http://docs.celeryproject.org/en/latest/contributing.html#other-bugs" rel="nofollow">contribution guide</a><br>
on reporting bugs.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have checked the <a href="https://github.com/celery/celery/issues?q=is%3Aissue+label%3A%22Issue+Type%3A+Bug+Report%22+-label%3A%22Category%3A+Documentation%22">issues list</a><br>
for similar or identical bug reports.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have checked the <a href="https://github.com/celery/celery/pulls?q=is%3Apr+label%3A%22PR+Type%3A+Bugfix%22+-label%3A%22Category%3A+Documentation%22">pull requests list</a><br>
for existing proposed fixes.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have checked the <a href="https://github.com/celery/celery/commits/master">commit log</a><br>
to find out if the bug was already fixed in the master branch.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have included all related issues and possible duplicate issues<br>
in this issue (If there are none, check this box anyway).</li>
</ul>
<h2 dir="auto">Mandatory Debugging Information</h2>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have included the output of <code class="notranslate">celery -A proj report</code> in the issue.<br>
(if you are not able to do this, then at least specify the Celery<br>
version affected).</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have verified that the issue exists against the <code class="notranslate">master</code> branch of Celery.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have included the contents of <code class="notranslate">pip freeze</code> in the issue.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have included all the versions of all the external dependencies required<br>
to reproduce this bug.</li>
</ul>
<h2 dir="auto">Optional Debugging Information</h2>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have tried reproducing the issue on more than one Python version<br>
and/or implementation.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have tried reproducing the issue on more than one message broker and/or<br>
result backend.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have tried reproducing the issue on more than one version of the message<br>
broker and/or result backend.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have tried reproducing the issue on more than one operating system.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have tried reproducing the issue on more than one workers pool.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have tried reproducing the issue with autoscaling, retries,<br>
ETA/Countdown &amp; rate limits disabled.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have tried reproducing the issue after downgrading<br>
and/or upgrading Celery and its dependencies.</li>
</ul>
<h2 dir="auto">Related Issues and Possible Duplicates</h2>

<h4 dir="auto">Related Issues</h4>
<ul dir="auto">
<li>None</li>
</ul>
<h4 dir="auto">Possible Duplicates</h4>
<ul dir="auto">
<li>None</li>
</ul>
<h2 dir="auto">Environment &amp; Settings</h2>

<p dir="auto"><strong>Celery version</strong>: 4.3.0</p>

<details>
<summary><b><code class="notranslate">celery report</code> Output:</b></summary>
<p dir="auto">
</p><div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=""><pre class="notranslate"><code class="notranslate"></code></pre></div>
<p dir="auto"></p>
</details>
<h1 dir="auto">Steps to Reproduce</h1>
<h2 dir="auto">Required Dependencies</h2>

<ul dir="auto">
<li><strong>Minimal Python Version</strong>: 3.7.1</li>
<li><strong>Minimal Celery Version</strong>: 4.3.0</li>
<li><strong>Minimal Kombu Version</strong>: 4.2.1</li>
<li><strong>Minimal Broker Version</strong>: redis==2.10.6</li>
<li><strong>Minimal Result Backend Version</strong>: N/A or Unknown</li>
<li><strong>Minimal OS and/or Kernel Version</strong>: N/A or Unknown</li>
<li><strong>Minimal Broker Client Version</strong>: redis==2.10.6</li>
<li><strong>Minimal Result Backend Client Version</strong>: N/A or Unknown</li>
</ul>
<h3 dir="auto">Python Packages</h3>

<details>
<summary><b><code class="notranslate">pip freeze</code> Output:</b></summary>
<p dir="auto">
</p><div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="amqp==2.2.2
appdirs==1.4.3
appnope==0.1.0
argh==0.26.2
attrs==17.4.0
autoflake==1.1
Babel==2.6.0
backports.shutil-get-terminal-size==1.0.0
billiard==3.5.0.3
bleach==3.0.2
boto3==1.7.22
botocore==1.10.22
cachetools==3.1.0
celery==4.3.0
certifi==2018.1.18
chardet==3.0.4
colorama==0.3.9
contextlib2==0.5.5
coverage==4.5.1
decorator==4.2.1
defusedxml==0.5.0
dj-database-url==0.5.0
Django==2.2
django-admin-rangefilter==0.3.12
django-allauth==0.35.0
django-celery-beat==1.1.1
django-cors-middleware==1.3.1
django-cursor-pagination==0.1.2
django-extensions==2.0.0
django-filter==1.1.0
django-formtools==2.1
django-otp==0.5.0
django-phonenumber-field==1.3.0
django-prometheus==1.0.15
django-two-factor-auth==1.8.0
django-viewflow-pro==1.4.2
djangorestframework==3.7.7
djangorestframework-simplejwt==3.2.2
djproxy==2.3.4
docopt==0.6.2
docutils==0.14
elasticsearch==6.0.0
enum34==1.1.6
ephem==3.7.6.0
factory-boy==2.11.1
Faker==0.8.11
flake8==3.5.0
flake8-isort==2.4
flake8-polyfill==1.0.2
freezegun==0.3.11
gevent==1.3.7
google-api-core==1.7.0
google-auth==1.6.2
googleapis-common-protos==1.5.6
graphene==2.0.1
graphene-django==2.0.0
graphql-core==2.0
graphql-relay==0.4.5
greenlet==0.4.15
grpcio==1.17.1
grpcio-tools==1.17.1
gunicorn==19.9.0
idna==2.6
img2pdf==0.3.2
ipdb==0.11
ipython==6.2.1
ipython-genutils==0.2.0
iso8601==0.1.12
isort==4.3.4
jedi==0.11.1
jmespath==0.9.3
jsonfield==2.0.2
kombu==4.2.1
mccabe==0.6.1
mock==2.0.0
mypy==0.641
mypy-extensions==0.4.1
mypy-protobuf==1.7
numpy==1.16.2
oauthlib==2.0.6
opencensus==0.1.10
packaging==17.1
parso==0.1.1
pathlib2==2.3.0
pathtools==0.1.2
pbr==3.1.1
pdfrw==0.4
permissive-search==0.1.7
pexpect==4.4.0
phonenumberslite==8.10.4
pickleshare==0.7.4
Pillow==5.4.1
pkginfo==1.4.2
pluggy==0.6.0
prometheus-client==0.5.0
promise==2.1
prompt-toolkit==1.0.15
protobuf==3.6.1
psycopg2-binary==2.7.6.1
ptyprocess==0.5.2
py==1.5.2
pyasn1==0.4.5
pyasn1-modules==0.2.4
pycodestyle==2.3.1
pycountry==18.5.26
pycurl==7.43.0.1
pyflakes==1.6.0
Pygments==2.2.0
PyJWT==1.6.1
pyparsing==2.2.0
pytest==3.4.1
pytest-cov==2.5.1
pytest-django==3.1.2
pytest-watch==4.1.0
pythia-python==1.5.2
python-dateutil==2.7.0
python-http-client==3.1.0
python3-openid==3.1.0
pytz==2018.3
PyYAML==3.12
qrcode==6.1
raven==6.6.0
readme-renderer==24.0
redis==2.10.6
reportlab==3.5.13
requests==2.20.0
requests_aws4auth==0.9
requests-mock==1.4.0
requests-oauthlib==0.8.0
requests-toolbelt==0.8.0
rsa==4.0
Rx==1.6.1
s3transfer==0.1.13
scandir==1.7
sendgrid==5.3.0
simplegeneric==0.8.1
singledispatch==3.4.0.3
six==1.11.0
snapshottest==0.5.0
termcolor==1.1.0
testfixtures==5.4.0
text-unidecode==1.2
tqdm==4.19.8
traitlets==4.3.2
twine==1.12.1
typed-ast==1.1.0
typing==3.6.4
ulid==1.1
Unidecode==1.0.22
urllib3==1.22
vine==1.1.4
watchdog==0.8.3
wcwidth==0.1.7
webencodings==0.5.1
whitenoise==3.3.1
wrapt==1.10.11
yapf==0.20.2"><pre class="notranslate"><code class="notranslate">amqp==2.2.2
appdirs==1.4.3
appnope==0.1.0
argh==0.26.2
attrs==17.4.0
autoflake==1.1
Babel==2.6.0
backports.shutil-get-terminal-size==1.0.0
billiard==3.5.0.3
bleach==3.0.2
boto3==1.7.22
botocore==1.10.22
cachetools==3.1.0
celery==4.3.0
certifi==2018.1.18
chardet==3.0.4
colorama==0.3.9
contextlib2==0.5.5
coverage==4.5.1
decorator==4.2.1
defusedxml==0.5.0
dj-database-url==0.5.0
Django==2.2
django-admin-rangefilter==0.3.12
django-allauth==0.35.0
django-celery-beat==1.1.1
django-cors-middleware==1.3.1
django-cursor-pagination==0.1.2
django-extensions==2.0.0
django-filter==1.1.0
django-formtools==2.1
django-otp==0.5.0
django-phonenumber-field==1.3.0
django-prometheus==1.0.15
django-two-factor-auth==1.8.0
django-viewflow-pro==1.4.2
djangorestframework==3.7.7
djangorestframework-simplejwt==3.2.2
djproxy==2.3.4
docopt==0.6.2
docutils==0.14
elasticsearch==6.0.0
enum34==1.1.6
ephem==3.7.6.0
factory-boy==2.11.1
Faker==0.8.11
flake8==3.5.0
flake8-isort==2.4
flake8-polyfill==1.0.2
freezegun==0.3.11
gevent==1.3.7
google-api-core==1.7.0
google-auth==1.6.2
googleapis-common-protos==1.5.6
graphene==2.0.1
graphene-django==2.0.0
graphql-core==2.0
graphql-relay==0.4.5
greenlet==0.4.15
grpcio==1.17.1
grpcio-tools==1.17.1
gunicorn==19.9.0
idna==2.6
img2pdf==0.3.2
ipdb==0.11
ipython==6.2.1
ipython-genutils==0.2.0
iso8601==0.1.12
isort==4.3.4
jedi==0.11.1
jmespath==0.9.3
jsonfield==2.0.2
kombu==4.2.1
mccabe==0.6.1
mock==2.0.0
mypy==0.641
mypy-extensions==0.4.1
mypy-protobuf==1.7
numpy==1.16.2
oauthlib==2.0.6
opencensus==0.1.10
packaging==17.1
parso==0.1.1
pathlib2==2.3.0
pathtools==0.1.2
pbr==3.1.1
pdfrw==0.4
permissive-search==0.1.7
pexpect==4.4.0
phonenumberslite==8.10.4
pickleshare==0.7.4
Pillow==5.4.1
pkginfo==1.4.2
pluggy==0.6.0
prometheus-client==0.5.0
promise==2.1
prompt-toolkit==1.0.15
protobuf==3.6.1
psycopg2-binary==2.7.6.1
ptyprocess==0.5.2
py==1.5.2
pyasn1==0.4.5
pyasn1-modules==0.2.4
pycodestyle==2.3.1
pycountry==18.5.26
pycurl==7.43.0.1
pyflakes==1.6.0
Pygments==2.2.0
PyJWT==1.6.1
pyparsing==2.2.0
pytest==3.4.1
pytest-cov==2.5.1
pytest-django==3.1.2
pytest-watch==4.1.0
pythia-python==1.5.2
python-dateutil==2.7.0
python-http-client==3.1.0
python3-openid==3.1.0
pytz==2018.3
PyYAML==3.12
qrcode==6.1
raven==6.6.0
readme-renderer==24.0
redis==2.10.6
reportlab==3.5.13
requests==2.20.0
requests_aws4auth==0.9
requests-mock==1.4.0
requests-oauthlib==0.8.0
requests-toolbelt==0.8.0
rsa==4.0
Rx==1.6.1
s3transfer==0.1.13
scandir==1.7
sendgrid==5.3.0
simplegeneric==0.8.1
singledispatch==3.4.0.3
six==1.11.0
snapshottest==0.5.0
termcolor==1.1.0
testfixtures==5.4.0
text-unidecode==1.2
tqdm==4.19.8
traitlets==4.3.2
twine==1.12.1
typed-ast==1.1.0
typing==3.6.4
ulid==1.1
Unidecode==1.0.22
urllib3==1.22
vine==1.1.4
watchdog==0.8.3
wcwidth==0.1.7
webencodings==0.5.1
whitenoise==3.3.1
wrapt==1.10.11
yapf==0.20.2
</code></pre></div>
<p dir="auto"></p>
</details>
<h3 dir="auto">Other Dependencies</h3>

<details>
<p dir="auto">
N/A
</p>
</details>
<h2 dir="auto">Minimally Reproducible Test Case</h2>

<details>
<p dir="auto">
</p><div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="@celery_app.task(name=&quot;some_name&quot;)
def some_function(
    *,
    first_kw: str = &quot;default value 1&quot;,
    second_kw: str,
    third_kw: str,
    n_minus_one_kw: str,
    last_kw: str = &quot;default value 2&quot;
):
    service.make_service(
        kw_1=first_kw,
        kw_2=second_lw,
        kw_3=third_kw,
        kw_4=n_minus_one_kw,
        kw_5=last_kw,
    )
"><pre class="notranslate"><span class="pl-en">@<span class="pl-s1">celery_app</span>.<span class="pl-en">task</span>(<span class="pl-s1">name</span><span class="pl-c1">=</span><span class="pl-s">"some_name"</span>)</span>
<span class="pl-k">def</span> <span class="pl-en">some_function</span>(
    <span class="pl-c1">*</span>,
    <span class="pl-s1">first_kw</span>: <span class="pl-s1">str</span> <span class="pl-c1">=</span> <span class="pl-s">"default value 1"</span>,
    <span class="pl-s1">second_kw</span>: <span class="pl-s1">str</span>,
    <span class="pl-s1">third_kw</span>: <span class="pl-s1">str</span>,
    <span class="pl-s1">n_minus_one_kw</span>: <span class="pl-s1">str</span>,
    <span class="pl-s1">last_kw</span>: <span class="pl-s1">str</span> <span class="pl-c1">=</span> <span class="pl-s">"default value 2"</span>
):
    <span class="pl-s1">service</span>.<span class="pl-en">make_service</span>(
        <span class="pl-s1">kw_1</span><span class="pl-c1">=</span><span class="pl-s1">first_kw</span>,
        <span class="pl-s1">kw_2</span><span class="pl-c1">=</span><span class="pl-s1">second_lw</span>,
        <span class="pl-s1">kw_3</span><span class="pl-c1">=</span><span class="pl-s1">third_kw</span>,
        <span class="pl-s1">kw_4</span><span class="pl-c1">=</span><span class="pl-s1">n_minus_one_kw</span>,
        <span class="pl-s1">kw_5</span><span class="pl-c1">=</span><span class="pl-s1">last_kw</span>,
    )</pre></div>
<p dir="auto"></p>
</details>
<h1 dir="auto">Expected Behavior</h1>

<p dir="auto">I expect that my function kwargs with default values will be optional. In example I suppose that first_kw and last_kw will be optional, and other will be required keyword arguments.</p>
<h1 dir="auto">Actual Behavior</h1>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="kwonlyargs_optional = [(kw, i) for i, kw in enumerate(spec.kwonlyargs[-split:])]"><pre class="notranslate"><code class="notranslate">kwonlyargs_optional = [(kw, i) for i, kw in enumerate(spec.kwonlyargs[-split:])]
</code></pre></div>
<p dir="auto">will return (kw, i) tuple for kwonlyargs in reversed order. But if I will pass default value for first and last element, and didn't provide default value for second, third, ... (n-1)th element, then this kwonlyargs_optional will assign optional parameter for (n-1)th element and latest elements, not for first and last. And it will cause an error for typing checking, if you wouldn't provide explicitly kward arg for first kwarg argument.</p>
<p dir="auto">Possible solution:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="kwonlyargs_optional = [(kw, i) for i, kw in enumerate(spec.kwonlydefaults.keys())]"><pre class="notranslate"><code class="notranslate">kwonlyargs_optional = [(kw, i) for i, kw in enumerate(spec.kwonlydefaults.keys())]
</code></pre></div>
<h1 dir="auto">Checklist</h1>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have verified that the issue exists against the <code class="notranslate">master</code> branch of Celery.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> This has already been asked to the <a href="https://groups.google.com/forum/#!forum/celery-users" rel="nofollow">discussion group</a> first.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have read the relevant section in the<br>
<a href="http://docs.celeryproject.org/en/latest/contributing.html#other-bugs" rel="nofollow">contribution guide</a><br>
on reporting bugs.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have checked the <a href="https://github.com/celery/celery/issues?q=is%3Aissue+label%3A%22Issue+Type%3A+Bug+Report%22+-label%3A%22Category%3A+Documentation%22">issues list</a><br>
for similar or identical bug reports.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have checked the <a href="https://github.com/celery/celery/pulls?q=is%3Apr+label%3A%22PR+Type%3A+Bugfix%22+-label%3A%22Category%3A+Documentation%22">pull requests list</a><br>
for existing proposed fixes.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have checked the <a href="https://github.com/celery/celery/commits/master">commit log</a><br>
to find out if the bug was already fixed in the master branch.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have included all related issues and possible duplicate issues<br>
in this issue (If there are none, check this box anyway).</li>
</ul>
<h2 dir="auto">Mandatory Debugging Information</h2>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have included the output of <code class="notranslate">celery -A proj report</code> in the issue.<br>
(if you are not able to do this, then at least specify the Celery<br>
version affected).</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have verified that the issue exists against the <code class="notranslate">master</code> branch of Celery.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have included the contents of <code class="notranslate">pip freeze</code> in the issue.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have included all the versions of all the external dependencies required<br>
to reproduce this bug.</li>
</ul>
<h2 dir="auto">Optional Debugging Information</h2>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have tried reproducing the issue after downgrading<br>
and/or upgrading Celery and its dependencies.</li>
</ul>
<h2 dir="auto">Related Issues and Possible Duplicates</h2>

<h4 dir="auto">Related Issues</h4>
<p dir="auto"><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="571454173" data-permission-text="Title is private" data-url="https://github.com/celery/celery/issues/5969" data-hovercard-type="issue" data-hovercard-url="/celery/celery/issues/5969/hovercard" href="https://github.com/celery/celery/issues/5969">#5969</a></p>
<h4 dir="auto">Possible Duplicates</h4>
<p dir="auto">My post<br>
<a href="https://stackoverflow.com/questions/66462079/celery-task-does-not-get-send-to-broker" rel="nofollow">https://stackoverflow.com/questions/66462079/celery-task-does-not-get-send-to-broker</a></p>
<h2 dir="auto">Environment &amp; Settings</h2>

<p dir="auto"><strong>Celery version</strong>: 5.0.5</p>

<details>
<summary><b><code class="notranslate">celery report</code> Output:</b></summary>
<p dir="auto">
</p><div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="software -&gt; celery:5.0.5 (singularity) kombu:5.0.2 py:3.7.8
            billiard:3.6.3.0 py-amqp:5.0.5
platform -&gt; system:Linux arch:64bit
            kernel version:4.15.0-20-generic imp:CPython
loader   -&gt; celery.loaders.app.AppLoader
settings -&gt; transport:pyamqp results:db+postgresql://docker:**@pg_db:5432/

broker: 'pyamqp://guest@my-rabbit//'
celery_accept_content: ['json']
environ: {
    'CELERY_BROKER': 'pyamqp://guest@my-rabbit//',
    'CELERY_BROKER_URL': 'amqp://guest:********@my-rabbit:5672//',
    'GPG_KEY': '********',
    'HOME': '/home/snake',
    'LANG': 'C.UTF-8',
    'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:',
    'PATH': '/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
    'PWD': '/home/snake',
    'PYTHONDONTWRITEBYTECODE': '1',
    'PYTHONUNBUFFERED': '1',
    'PYTHON_VERSION': '3.7.8',
    'SHLVL': '1',
    'TERM': 'xterm',
    '_': '/usr/local/bin/celery'}
result_backend: 'db+postgresql://docker:********@pg_db:5432/'
result_persistent: False
result_serializer: 'json'
task_serializer: 'json'
worker_concurrency: 16
deprecated_settings: None
"><pre class="notranslate"><code class="notranslate">software -&gt; celery:5.0.5 (singularity) kombu:5.0.2 py:3.7.8
            billiard:3.6.3.0 py-amqp:5.0.5
platform -&gt; system:Linux arch:64bit
            kernel version:4.15.0-20-generic imp:CPython
loader   -&gt; celery.loaders.app.AppLoader
settings -&gt; transport:pyamqp results:db+postgresql://docker:**@pg_db:5432/

broker: 'pyamqp://guest@my-rabbit//'
celery_accept_content: ['json']
environ: {
    'CELERY_BROKER': 'pyamqp://guest@my-rabbit//',
    'CELERY_BROKER_URL': 'amqp://guest:********@my-rabbit:5672//',
    'GPG_KEY': '********',
    'HOME': '/home/snake',
    'LANG': 'C.UTF-8',
    'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:',
    'PATH': '/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
    'PWD': '/home/snake',
    'PYTHONDONTWRITEBYTECODE': '1',
    'PYTHONUNBUFFERED': '1',
    'PYTHON_VERSION': '3.7.8',
    'SHLVL': '1',
    'TERM': 'xterm',
    '_': '/usr/local/bin/celery'}
result_backend: 'db+postgresql://docker:********@pg_db:5432/'
result_persistent: False
result_serializer: 'json'
task_serializer: 'json'
worker_concurrency: 16
deprecated_settings: None

</code></pre></div>
<p dir="auto"></p>
</details>
<h1 dir="auto">Steps to Reproduce</h1>
<h2 dir="auto">Required Dependencies</h2>

<ul dir="auto">
<li><strong>Minimal Python Version</strong>: 3.7</li>
<li><strong>Minimal Celery Version</strong>: 4.7.7</li>
<li><strong>Minimal Kombu Version</strong>: 5.0.2</li>
<li><strong>Minimal Broker Version</strong>: RabbitMQ</li>
<li><strong>Minimal Result Backend Version</strong>: N/A</li>
<li><strong>Minimal OS and/or Kernel Version</strong>: 4.15.0-20-generic <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="30803" data-permission-text="Title is private" data-url="https://github.com/celery/celery/issues/21" data-hovercard-type="issue" data-hovercard-url="/celery/celery/issues/21/hovercard" href="https://github.com/celery/celery/issues/21">#21</a>-Ubuntu SMP</li>
<li><strong>Minimal Broker Client Version</strong>: N/A or Unknown</li>
<li><strong>Minimal Result Backend Client Version</strong>: N/A or Unknown</li>
</ul>
<h3 dir="auto">Python Packages</h3>

<details>
<summary><b><code class="notranslate">pip freeze</code> Output:</b></summary>
<p dir="auto">
</p><div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="alembic==1.5.5
amqp==5.0.5
Beaker==1.11.0
billiard==3.6.3.0
celery==5.0.5
certifi==2020.12.5
cffi==1.14.5
chardet==4.0.0
click==7.1.2
click-didyoumean==0.0.3
click-plugins==1.1.1
click-repl==0.1.6
cryptography==3.4.6
defusedxml==0.7.0
et-xmlfile==1.0.1
Flask==1.1.1
Flask-Migrate==2.5.3
Flask-pyoidc==3.4.0
Flask-SQLAlchemy==2.4.1
Flask-Testing==0.8.1
Flask-WTF==0.14.3
future==0.18.2
gunicorn==20.0.4
idna==2.10
importlib-metadata==3.7.0
importlib-resources==5.1.2
itsdangerous==1.1.0
jdcal==1.4.1
Jinja2==2.11.3
kombu==5.0.2
Mako==1.1.4
MarkupSafe==1.1.1
oic==1.1.2
openpyxl==3.0.3
prompt-toolkit==3.0.16
psycopg2==2.8.6
pycparser==2.20
pycryptodomex==3.10.1
pyjwkest==1.4.2
pyodbc==4.0.30
python-dateutil==2.8.1
python-editor==1.0.4
python-Levenshtein==0.12.2
pytz==2021.1
requests==2.25.1
six==1.15.0
SQLAlchemy==1.3.23
typing-extensions==3.7.4.3
urllib3==1.26.3
vine==5.0.0
wcwidth==0.2.5
Werkzeug==1.0.1
WTForms==2.3.3
zipp==3.4.1"><pre class="notranslate"><code class="notranslate">alembic==1.5.5
amqp==5.0.5
Beaker==1.11.0
billiard==3.6.3.0
celery==5.0.5
certifi==2020.12.5
cffi==1.14.5
chardet==4.0.0
click==7.1.2
click-didyoumean==0.0.3
click-plugins==1.1.1
click-repl==0.1.6
cryptography==3.4.6
defusedxml==0.7.0
et-xmlfile==1.0.1
Flask==1.1.1
Flask-Migrate==2.5.3
Flask-pyoidc==3.4.0
Flask-SQLAlchemy==2.4.1
Flask-Testing==0.8.1
Flask-WTF==0.14.3
future==0.18.2
gunicorn==20.0.4
idna==2.10
importlib-metadata==3.7.0
importlib-resources==5.1.2
itsdangerous==1.1.0
jdcal==1.4.1
Jinja2==2.11.3
kombu==5.0.2
Mako==1.1.4
MarkupSafe==1.1.1
oic==1.1.2
openpyxl==3.0.3
prompt-toolkit==3.0.16
psycopg2==2.8.6
pycparser==2.20
pycryptodomex==3.10.1
pyjwkest==1.4.2
pyodbc==4.0.30
python-dateutil==2.8.1
python-editor==1.0.4
python-Levenshtein==0.12.2
pytz==2021.1
requests==2.25.1
six==1.15.0
SQLAlchemy==1.3.23
typing-extensions==3.7.4.3
urllib3==1.26.3
vine==5.0.0
wcwidth==0.2.5
Werkzeug==1.0.1
WTForms==2.3.3
zipp==3.4.1
</code></pre></div>
<p dir="auto"></p>
</details>
<h3 dir="auto">Other Dependencies</h3>

<details>
<p dir="auto">
N/A
</p>
</details>
<h3 dir="auto">Broker details</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Listeners

Interface: [::], port: 15672, protocol: http, purpose: HTTP API
Interface: [::], port: 15692, protocol: http/prometheus, purpose: Prometheus exporter API over HTTP
Interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication
Interface: [::], port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0"><pre class="notranslate"><code class="notranslate">Listeners

Interface: [::], port: 15672, protocol: http, purpose: HTTP API
Interface: [::], port: 15692, protocol: http/prometheus, purpose: Prometheus exporter API over HTTP
Interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication
Interface: [::], port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0
</code></pre></div>
<h1 dir="auto">Expected Behavior</h1>
<p dir="auto">.delay and .apply_async tasks are send to rabbitmq broker.</p>
<h1 dir="auto">Actual Behavior</h1>
<p dir="auto">When I try to send my task to broker (RabbitMQ) it hangs.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# python shell
promise = foo.s(first_arg=&quot;2&quot;).apply_async()
# blocking indefinitely. I expected a promise object."><pre class="notranslate"><span class="pl-c"># python shell</span>
<span class="pl-s1">promise</span> <span class="pl-c1">=</span> <span class="pl-s1">foo</span>.<span class="pl-en">s</span>(<span class="pl-s1">first_arg</span><span class="pl-c1">=</span><span class="pl-s">"2"</span>).<span class="pl-en">apply_async</span>()
<span class="pl-c"># blocking indefinitely. I expected a promise object.</span></pre></div>
<p dir="auto">If I run the task synchronously it works as expected.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# python shell
promise = foo.s(first_arg=&quot;2&quot;).apply()
&gt;&gt;&gt; hello argument 2"><pre class="notranslate"><span class="pl-c"># python shell</span>
<span class="pl-s1">promise</span> <span class="pl-c1">=</span> <span class="pl-s1">foo</span>.<span class="pl-en">s</span>(<span class="pl-s1">first_arg</span><span class="pl-c1">=</span><span class="pl-s">"2"</span>).<span class="pl-en">apply</span>()
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">hello</span> <span class="pl-s1">argument</span> <span class="pl-c1">2</span></pre></div>
<p dir="auto">If I interrupt <code class="notranslate">.apply_async()</code> with ctrl+c I get a traceback with some clues:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;/usr/local/lib/python3.7/site-packages/kombu/utils/functional.py&quot;, line 32, 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 &quot;/usr/local/lib/python3.7/site-packages/amqp/transport.py&quot;, line 173, in _connect
    host, port, family, socket.SOCK_STREAM, SOL_TCP)
  File &quot;/usr/local/lib/python3.7/socket.py&quot;, line 752, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -9] Address family for hostname not supported

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File &quot;/usr/local/lib/python3.7/site-packages/kombu/utils/functional.py&quot;, line 325, in retry_over_time
    return fun(*args, **kwargs)
  File &quot;/usr/local/lib/python3.7/site-packages/kombu/connection.py&quot;, line 866, in _connection_factory
    self._connection = self._establish_connection()
  File &quot;/usr/local/lib/python3.7/site-packages/kombu/connection.py&quot;, line 801, in _establish_connection
    conn = self.transport.establish_connection()
  File &quot;/usr/local/lib/python3.7/site-packages/kombu/transport/pyamqp.py&quot;, line 128, in establish_connection
    conn.connect()
  File &quot;/usr/local/lib/python3.7/site-packages/amqp/connection.py&quot;, line 323, in connect
    self.transport.connect()
  File &quot;/usr/local/lib/python3.7/site-packages/amqp/transport.py&quot;, line 113, in connect
    self._connect(self.host, self.port, self.connect_timeout)
  File &quot;/usr/local/lib/python3.7/site-packages/amqp/transport.py&quot;, line 184, in _connect
    &quot;failed to resolve broker hostname&quot;))
  File &quot;/usr/local/lib/python3.7/site-packages/amqp/transport.py&quot;, line 197, in _connect
    self.sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
  File &quot;/usr/local/lib/python3.7/site-packages/celery/canvas.py&quot;, line 225, in apply_async
    return _apply(args, kwargs, **options)
  File &quot;/usr/local/lib/python3.7/site-packages/celery/app/task.py&quot;, line 565, in apply_async
    **options
  File &quot;/usr/local/lib/python3.7/site-packages/celery/app/base.py&quot;, line 749, in send_task
    amqp.send_task_message(P, name, message, **options)
  File &quot;/usr/local/lib/python3.7/site-packages/celery/app/amqp.py&quot;, line 532, in send_task_message
    **properties
  File &quot;/usr/local/lib/python3.7/site-packages/kombu/messaging.py&quot;, line 178, in publish
    exchange_name, declare,
  File &quot;/usr/local/lib/python3.7/site-packages/kombu/connection.py&quot;, line 525, in _ensured
    return fun(*args, **kwargs)
  File &quot;/usr/local/lib/python3.7/site-packages/kombu/messaging.py&quot;, line 184, in _publish
    channel = self.channel
  File &quot;/usr/local/lib/python3.7/site-packages/kombu/messaging.py&quot;, line 206, in _get_channel
    channel = self._channel = channel()
  File &quot;/usr/local/lib/python3.7/site-packages/kombu/utils/functional.py&quot;, line 34, in __call__
    value = self.__value__ = self.__contract__()
  File &quot;/usr/local/lib/python3.7/site-packages/kombu/messaging.py&quot;, line 221, in &lt;lambda&gt;
    channel = ChannelPromise(lambda: connection.default_channel)
  File &quot;/usr/local/lib/python3.7/site-packages/kombu/connection.py&quot;, line 884, in default_channel
    self._ensure_connection(**conn_opts)
  File &quot;/usr/local/lib/python3.7/site-packages/kombu/connection.py&quot;, line 439, in _ensure_connection
    callback, timeout=timeout
  File &quot;/usr/local/lib/python3.7/site-packages/kombu/utils/functional.py&quot;, line 339, in retry_over_time
    sleep(1.0)"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/kombu/utils/functional.py", line 32, 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.7/site-packages/amqp/transport.py", line 173, in _connect
    host, port, family, socket.SOCK_STREAM, SOL_TCP)
  File "/usr/local/lib/python3.7/socket.py", line 752, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -9] Address family for hostname not supported

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/kombu/utils/functional.py", line 325, in retry_over_time
    return fun(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/kombu/connection.py", line 866, in _connection_factory
    self._connection = self._establish_connection()
  File "/usr/local/lib/python3.7/site-packages/kombu/connection.py", line 801, in _establish_connection
    conn = self.transport.establish_connection()
  File "/usr/local/lib/python3.7/site-packages/kombu/transport/pyamqp.py", line 128, in establish_connection
    conn.connect()
  File "/usr/local/lib/python3.7/site-packages/amqp/connection.py", line 323, in connect
    self.transport.connect()
  File "/usr/local/lib/python3.7/site-packages/amqp/transport.py", line 113, in connect
    self._connect(self.host, self.port, self.connect_timeout)
  File "/usr/local/lib/python3.7/site-packages/amqp/transport.py", line 184, in _connect
    "failed to resolve broker hostname"))
  File "/usr/local/lib/python3.7/site-packages/amqp/transport.py", line 197, in _connect
    self.sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "/usr/local/lib/python3.7/site-packages/celery/canvas.py", line 225, in apply_async
    return _apply(args, kwargs, **options)
  File "/usr/local/lib/python3.7/site-packages/celery/app/task.py", line 565, in apply_async
    **options
  File "/usr/local/lib/python3.7/site-packages/celery/app/base.py", line 749, in send_task
    amqp.send_task_message(P, name, message, **options)
  File "/usr/local/lib/python3.7/site-packages/celery/app/amqp.py", line 532, in send_task_message
    **properties
  File "/usr/local/lib/python3.7/site-packages/kombu/messaging.py", line 178, in publish
    exchange_name, declare,
  File "/usr/local/lib/python3.7/site-packages/kombu/connection.py", line 525, in _ensured
    return fun(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/kombu/messaging.py", line 184, in _publish
    channel = self.channel
  File "/usr/local/lib/python3.7/site-packages/kombu/messaging.py", line 206, in _get_channel
    channel = self._channel = channel()
  File "/usr/local/lib/python3.7/site-packages/kombu/utils/functional.py", line 34, in __call__
    value = self.__value__ = self.__contract__()
  File "/usr/local/lib/python3.7/site-packages/kombu/messaging.py", line 221, in &lt;lambda&gt;
    channel = ChannelPromise(lambda: connection.default_channel)
  File "/usr/local/lib/python3.7/site-packages/kombu/connection.py", line 884, in default_channel
    self._ensure_connection(**conn_opts)
  File "/usr/local/lib/python3.7/site-packages/kombu/connection.py", line 439, in _ensure_connection
    callback, timeout=timeout
  File "/usr/local/lib/python3.7/site-packages/kombu/utils/functional.py", line 339, in retry_over_time
    sleep(1.0)
</code></pre></div>
<p dir="auto">The broker connection string looks like this in the system:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="~$ env | grep BROKER
CELERY_BROKER=pyamqp://guest@172.23.0.3//"><pre class="notranslate"><span class="pl-k">~</span>$ env <span class="pl-k">|</span> grep BROKER
CELERY_BROKER=pyamqp://guest@172.23.0.3//</pre></div>
<p dir="auto">The broker connection string in python:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# python shell
from src.celery import app
app.pool.connection
&gt;&gt;&gt; Connection: amqp://guest:**@localhost:5672//"><pre class="notranslate"><span class="pl-c"># python shell</span>
<span class="pl-k">from</span> <span class="pl-s1">src</span>.<span class="pl-s1">celery</span> <span class="pl-k">import</span> <span class="pl-s1">app</span>
<span class="pl-s1">app</span>.<span class="pl-s1">pool</span>.<span class="pl-s1">connection</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-v">Connection</span>: <span class="pl-s1">amqp</span>:<span class="pl-c1">//</span><span class="pl-s1">guest</span>:<span class="pl-c1">**</span>@<span class="pl-s1">localhost</span>:<span class="pl-c1">5672</span><span class="pl-c1">//</span></pre></div>
<p dir="auto">Before you suggest that RabbitMQ is not running, or the connection string is bad; my celery worker (consumer) process is able to connect with the same connection string.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="-------------- celery@f9ab48fc6b63 v5.0.5 (singularity)
--- ***** -----
-- ******* ---- Linux-4.15.0-20-generic-x86_64-with-debian-9.12 2021-03-05 07:56:29
- *** --- * ---
- ** ---------- [config]
- ** ---------- .&gt; app:         celery_statst_api:0x7f15b6de0450
- ** ---------- .&gt; transport:   amqp://guest:**@my-rabbit:5672//
- ** ---------- .&gt; results:     postgresql://docker:**@pg_db:5432/
- *** --- * --- .&gt; concurrency: 16 (prefork)
-- ******* ---- .&gt; task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
 -------------- [queues]
                .&gt; celery           exchange=celery(direct) key=celery


[tasks]
  . foo_task
  . (long list of tasks)

[2021-03-05 07:56:30,564: INFO/MainProcess] Connected to amqp://guest:**@my-rabbit:5672//
[2021-03-05 07:56:30,581: INFO/MainProcess] mingle: searching for neighbors
[2021-03-05 07:56:31,622: INFO/MainProcess] mingle: all alone
[2021-03-05 07:56:31,647: INFO/MainProcess] celery@f9ab48fc6b63 ready."><pre class="notranslate"><code class="notranslate">-------------- celery@f9ab48fc6b63 v5.0.5 (singularity)
--- ***** -----
-- ******* ---- Linux-4.15.0-20-generic-x86_64-with-debian-9.12 2021-03-05 07:56:29
- *** --- * ---
- ** ---------- [config]
- ** ---------- .&gt; app:         celery_statst_api:0x7f15b6de0450
- ** ---------- .&gt; transport:   amqp://guest:**@my-rabbit:5672//
- ** ---------- .&gt; results:     postgresql://docker:**@pg_db:5432/
- *** --- * --- .&gt; concurrency: 16 (prefork)
-- ******* ---- .&gt; task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
 -------------- [queues]
                .&gt; celery           exchange=celery(direct) key=celery


[tasks]
  . foo_task
  . (long list of tasks)

[2021-03-05 07:56:30,564: INFO/MainProcess] Connected to amqp://guest:**@my-rabbit:5672//
[2021-03-05 07:56:30,581: INFO/MainProcess] mingle: searching for neighbors
[2021-03-05 07:56:31,622: INFO/MainProcess] mingle: all alone
[2021-03-05 07:56:31,647: INFO/MainProcess] celery@f9ab48fc6b63 ready.
</code></pre></div>
<p dir="auto">This is how I connect app/producer to the broker.<br>
The file celeryconfig.py contains setup for broker url backend, concurrency, etc.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# celery_tasks.py
# imports...
app = Celery('celery_statst_api')
app.config_from_object(celeryconfig) # import config file

@app.task(name=&quot;foo&quot;)
def foo(first_arg: str) -&gt; str:
    print(f&quot;thanks for {first_arg}&quot;)
    return &quot;OK&quot;
"><pre class="notranslate"><span class="pl-c"># celery_tasks.py</span>
<span class="pl-c"># imports...</span>
<span class="pl-s1">app</span> <span class="pl-c1">=</span> <span class="pl-v">Celery</span>(<span class="pl-s">'celery_statst_api'</span>)
<span class="pl-s1">app</span>.<span class="pl-en">config_from_object</span>(<span class="pl-s1">celeryconfig</span>) <span class="pl-c"># import config file</span>

<span class="pl-en">@<span class="pl-s1">app</span>.<span class="pl-en">task</span>(<span class="pl-s1">name</span><span class="pl-c1">=</span><span class="pl-s">"foo"</span>)</span>
<span class="pl-k">def</span> <span class="pl-en">foo</span>(<span class="pl-s1">first_arg</span>: <span class="pl-s1">str</span>) <span class="pl-c1">-&gt;</span> <span class="pl-s1">str</span>:
    <span class="pl-en">print</span>(<span class="pl-s">f"thanks for <span class="pl-s1"><span class="pl-kos">{</span><span class="pl-s1">first_arg</span><span class="pl-kos">}</span></span>"</span>)
    <span class="pl-k">return</span> <span class="pl-s">"OK"</span></pre></div>