<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" checked=""> 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" checked=""> 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" 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" checked=""> 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"> 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>:</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.6.9
            billiard:3.6.4.0 py-amqp:5.0.6
platform -&gt; system:Linux arch:64bit, ELF
            kernel version:4.15.0-140-generic imp:CPython
loader   -&gt; celery.loaders.default.Loader
settings -&gt; transport:amqp results:mongodb+srv://md_app_user:**@md-mongo.privatecircle.co/master_docs

accept_content: ['json']
broker_url: 'amqp://md_app_user:********@****************:5672//master_docs'
default_timezone: 'Asia/Kolkata'
imports: ['tasks']
result_backend: 'mongodb+srv://md_app_user:********@******************/master_docs'
result_serializer: 'json'
task_serializer: 'json'
timezone: 'Asia/Kolkata'
deprecated_settings: None"><pre class="notranslate"><code class="notranslate">software -&gt; celery:5.0.5 (singularity) kombu:5.0.2 py:3.6.9
            billiard:3.6.4.0 py-amqp:5.0.6
platform -&gt; system:Linux arch:64bit, ELF
            kernel version:4.15.0-140-generic imp:CPython
loader   -&gt; celery.loaders.default.Loader
settings -&gt; transport:amqp results:mongodb+srv://md_app_user:**@md-mongo.privatecircle.co/master_docs

accept_content: ['json']
broker_url: 'amqp://md_app_user:********@****************:5672//master_docs'
default_timezone: 'Asia/Kolkata'
imports: ['tasks']
result_backend: 'mongodb+srv://md_app_user:********@******************/master_docs'
result_serializer: 'json'
task_serializer: 'json'
timezone: 'Asia/Kolkata'
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.6.9</li>
<li><strong>Minimal Celery Version</strong>: 5.0.3</li>
<li><strong>Minimal Kombu Version</strong>: 5.0.2</li>
<li><strong>Minimal Broker Version</strong>: RabbitMQ 3.8.11</li>
<li><strong>Minimal Result Backend Version</strong>: Mongo 4.4</li>
<li><strong>Minimal OS and/or Kernel Version</strong>: Ubuntu 18.04.5 (Linux kernel 4.15.0-140)</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="amqp==5.0.6
backcall==0.2.0
billiard==3.6.4.0
boto3==1.17.51
botocore==1.20.51
cached-property==1.5.2
cchardet==2.1.7
celery==5.0.5
certifi==2020.12.5
chardet==4.0.0
click==7.1.2
click-didyoumean==0.0.3
click-plugins==1.1.1
click-repl==0.1.6
decorator==5.0.6
dnspython==2.1.0
idna==2.10
importlib-metadata==3.10.0
ipython==7.16.1
ipython-genutils==0.2.0
jedi==0.17.2
jmespath==0.10.0
kombu==5.0.2
lxml==4.6.3
parso==0.7.1
pexpect==4.8.0
pickleshare==0.7.5
prompt-toolkit==3.0.18
ptyprocess==0.7.0
Pygments==2.8.1
pymongo==3.11.3
python-dateutil==2.8.1
python-magic==0.4.22
pytz==2021.1
requests==2.25.1
s3transfer==0.3.6
six==1.15.0
traitlets==4.3.3
typing-extensions==3.7.4.3
urllib3==1.26.4
vine==5.0.0
wcwidth==0.2.5
zipp==3.4.1"><pre class="notranslate"><code class="notranslate">amqp==5.0.6
backcall==0.2.0
billiard==3.6.4.0
boto3==1.17.51
botocore==1.20.51
cached-property==1.5.2
cchardet==2.1.7
celery==5.0.5
certifi==2020.12.5
chardet==4.0.0
click==7.1.2
click-didyoumean==0.0.3
click-plugins==1.1.1
click-repl==0.1.6
decorator==5.0.6
dnspython==2.1.0
idna==2.10
importlib-metadata==3.10.0
ipython==7.16.1
ipython-genutils==0.2.0
jedi==0.17.2
jmespath==0.10.0
kombu==5.0.2
lxml==4.6.3
parso==0.7.1
pexpect==4.8.0
pickleshare==0.7.5
prompt-toolkit==3.0.18
ptyprocess==0.7.0
Pygments==2.8.1
pymongo==3.11.3
python-dateutil==2.8.1
python-magic==0.4.22
pytz==2021.1
requests==2.25.1
s3transfer==0.3.6
six==1.15.0
traitlets==4.3.3
typing-extensions==3.7.4.3
urllib3==1.26.4
vine==5.0.0
wcwidth==0.2.5
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>
<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="# test.py
import celery
app = celery.Celery('proj')"><pre class="notranslate"><span class="pl-c"># test.py</span>
<span class="pl-k">import</span> <span class="pl-s1">celery</span>
<span class="pl-s1">app</span> <span class="pl-c1">=</span> <span class="pl-s1">celery</span>.<span class="pl-v">Celery</span>(<span class="pl-s">'proj'</span>)</pre></div>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ celery -A test amqp repl
&gt; exchange.declare
"><pre class="notranslate">$ celery -A <span class="pl-c1">test</span> amqp repl
<span class="pl-k">&gt;</span> exchange.declare
</pre></div>
<p dir="auto"></p>
</details>
<h1 dir="auto">Expected Behavior</h1>

<p dir="auto">The AMQP interactive shell should accept this command and execute it and then prompt for the next command.</p>
<h1 dir="auto">Actual Behavior</h1>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;/home/privatecircle/.virtualenvs/mca_document_manager/bin/celery&quot;, line 8, in &lt;module&gt;
    sys.exit(main())
  File &quot;/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/celery/__main__.py&quot;, line 15, in main
    sys.exit(_main())
  File &quot;/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/celery/bin/celery.py&quot;, line 213, in main
    return celery(auto_envvar_prefix=&quot;CELERY&quot;)
  File &quot;/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py&quot;, line 829, in __call__
    return self.main(*args, **kwargs)
  File &quot;/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py&quot;, line 782, in main
    rv = self.invoke(ctx)
  File &quot;/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py&quot;, line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File &quot;/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py&quot;, line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File &quot;/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py&quot;, line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File &quot;/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py&quot;, line 610, in invoke
    return callback(*args, **kwargs)
  File &quot;/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/decorators.py&quot;, line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File &quot;/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click_repl/__init__.py&quot;, line 248, in repl
    group.invoke(ctx)
  File &quot;/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py&quot;, line 1256, in invoke
    Command.invoke(self, ctx)
  File &quot;/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py&quot;, line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File &quot;/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py&quot;, line 610, in invoke
    return callback(*args, **kwargs)
  File &quot;/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/decorators.py&quot;, line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File &quot;/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/celery/bin/base.py&quot;, line 120, in caller
    app = ctx.obj.app
AttributeError: 'AMQPContext' object has no attribute 'app'"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "/home/privatecircle/.virtualenvs/mca_document_manager/bin/celery", line 8, in &lt;module&gt;
    sys.exit(main())
  File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/celery/__main__.py", line 15, in main
    sys.exit(_main())
  File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/celery/bin/celery.py", line 213, in main
    return celery(auto_envvar_prefix="CELERY")
  File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click_repl/__init__.py", line 248, in repl
    group.invoke(ctx)
  File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py", line 1256, in invoke
    Command.invoke(self, ctx)
  File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/celery/bin/base.py", line 120, in caller
    app = ctx.obj.app
AttributeError: 'AMQPContext' object has no attribute 'app'
</code></pre></div>
<p dir="auto">F821 is one of the most useful flake8 rules, however it's currently disabled because type comments reference undefined names.</p>
<p dir="auto">it can be fixed with a conditional dependency on <code class="notranslate">typing</code> or importing typing in an <code class="notranslate">if False:</code> block, see discussion here: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="545196257" data-permission-text="Title is private" data-url="https://github.com/PyCQA/pyflakes/issues/501" data-hovercard-type="issue" data-hovercard-url="/PyCQA/pyflakes/issues/501/hovercard" href="https://github.com/PyCQA/pyflakes/issues/501">PyCQA/pyflakes#501</a></p>
<h1 dir="auto">conditional dep</h1>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# requirements.txt
typing; python_version &lt; '3.5'"><pre class="notranslate"><code class="notranslate"># requirements.txt
typing; python_version &lt; '3.5'
</code></pre></div>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# some_annotated.py
from typing import Any, Tuple

if typing.TYPE_CHECKING:
    from celery import Celery"><pre class="notranslate"><span class="pl-c"># some_annotated.py</span>
<span class="pl-k">from</span> <span class="pl-s1">typing</span> <span class="pl-k">import</span> <span class="pl-v">Any</span>, <span class="pl-v">Tuple</span>

<span class="pl-k">if</span> <span class="pl-s1">typing</span>.<span class="pl-v">TYPE_CHECKING</span>:
    <span class="pl-k">from</span> <span class="pl-s1">celery</span> <span class="pl-k">import</span> <span class="pl-v">Celery</span></pre></div>
<h1 dir="auto"><code class="notranslate">if False:</code></h1>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# some_annotated.py

if False:
    from typing import Any, Tuple
    from celery import Celery"><pre class="notranslate"><span class="pl-c"># some_annotated.py</span>

<span class="pl-k">if</span> <span class="pl-c1">False</span>:
    <span class="pl-k">from</span> <span class="pl-s1">typing</span> <span class="pl-k">import</span> <span class="pl-v">Any</span>, <span class="pl-v">Tuple</span>
    <span class="pl-k">from</span> <span class="pl-s1">celery</span> <span class="pl-k">import</span> <span class="pl-v">Celery</span></pre></div>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/auvipy/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/auvipy">@auvipy</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/thedrow/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/thedrow">@thedrow</a> do you have a preferred <code class="notranslate">typing</code> import approach? mine is to add the conditional dep</p>

<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 checked the <a href="https://github.com/celery/celery/issues?q=is%3Aissue+label%3A%22Issue+Type%3A+Enhancement%22+-label%3A%22Category%3A+Documentation%22">issues list</a><br>
for similar or identical enhancement to an existing feature.</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%22Issue+Type%3A+Enhancement%22+-label%3A%22Category%3A+Documentation%22">pull requests list</a><br>
for existing proposed enhancements.</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 if the same enhancement was already implemented in the<br>
master branch.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have included all related issues and possible duplicate issues in this issue<br>
(If there are none, check this box anyway).</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>
<h1 dir="auto">Brief Summary</h1>

<h1 dir="auto">Design</h1>
<h2 dir="auto">Architectural Considerations</h2>

<p dir="auto">None</p>
<h2 dir="auto">Proposed Behavior</h2>

<h2 dir="auto">Proposed UI/UX</h2>

<h2 dir="auto">Diagrams</h2>

<p dir="auto">N/A</p>
<h2 dir="auto">Alternatives</h2>

<p dir="auto">None</p>