<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" 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"> 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"> 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"> 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"> I have tried reproducing the issue after downgrading<br>
and/or upgrading Celery and its dependencies.</li>
</ul>
<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.4.0 (cliffs)</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:4.4.0 (cliffs) kombu:4.6.7 py:3.6.9
            billiard:3.6.1.0 py-amqp:2.5.2
platform -&gt; system:Linux arch:64bit, ELF
            kernel version:4.15.0-76-generic imp:CPython
loader   -&gt; celery.loaders.default.Loader
settings -&gt; transport:amqp results:disabled"><pre class="notranslate"><code class="notranslate">software -&gt; celery:4.4.0 (cliffs) kombu:4.6.7 py:3.6.9
            billiard:3.6.1.0 py-amqp:2.5.2
platform -&gt; system:Linux arch:64bit, ELF
            kernel version:4.15.0-76-generic imp:CPython
loader   -&gt; celery.loaders.default.Loader
settings -&gt; transport:amqp results:disabled
</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>: N/A or Unknown</li>
<li><strong>Minimal Celery Version</strong>: N/A or Unknown</li>
<li><strong>Minimal Kombu Version</strong>: N/A or Unknown</li>
<li><strong>Minimal Broker Version</strong>: RabbitMQ 3.6.10</li>
<li><strong>Minimal Result Backend Version</strong>: DB Postgres</li>
<li><strong>Minimal OS and/or Kernel Version</strong>: N/A or Unknown</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=""><pre class="notranslate"><code class="notranslate">
</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="task = chain(group(AClass.execute.si(&quot;&quot;, &quot;&quot;),
                   AClass.execute.si(&quot;&quot;, &quot;&quot;),
                   AClass.execute.si(&quot;&quot;, &quot;&quot;)),
             group(AClass.execute.si(&quot;&quot;, &quot;&quot;),
                   AClass.execute.si(&quot;&quot;, &quot;&quot;),
                   AClass.execute.si(&quot;&quot;, &quot;&quot;)),
             group(AClass.execute.si(&quot;&quot;, &quot;&quot;)),
             group(AClass.execute.si(&quot;&quot;, &quot;))
)"><pre class="notranslate"><span class="pl-s1">task</span> <span class="pl-c1">=</span> <span class="pl-en">chain</span>(<span class="pl-en">group</span>(<span class="pl-v">AClass</span>.<span class="pl-s1">execute</span>.<span class="pl-en">si</span>(<span class="pl-s">""</span>, <span class="pl-s">""</span>),
                   <span class="pl-v">AClass</span>.<span class="pl-s1">execute</span>.<span class="pl-en">si</span>(<span class="pl-s">""</span>, <span class="pl-s">""</span>),
                   <span class="pl-v">AClass</span>.<span class="pl-s1">execute</span>.<span class="pl-en">si</span>(<span class="pl-s">""</span>, <span class="pl-s">""</span>)),
             <span class="pl-en">group</span>(<span class="pl-v">AClass</span>.<span class="pl-s1">execute</span>.<span class="pl-en">si</span>(<span class="pl-s">""</span>, <span class="pl-s">""</span>),
                   <span class="pl-v">AClass</span>.<span class="pl-s1">execute</span>.<span class="pl-en">si</span>(<span class="pl-s">""</span>, <span class="pl-s">""</span>),
                   <span class="pl-v">AClass</span>.<span class="pl-s1">execute</span>.<span class="pl-en">si</span>(<span class="pl-s">""</span>, <span class="pl-s">""</span>)),
             <span class="pl-en">group</span>(<span class="pl-v">AClass</span>.<span class="pl-s1">execute</span>.<span class="pl-en">si</span>(<span class="pl-s">""</span>, <span class="pl-s">""</span>)),
             <span class="pl-en">group</span>(<span class="pl-v">AClass</span>.<span class="pl-s1">execute</span>.<span class="pl-en">si</span>(<span class="pl-s">""</span>, "))
)</pre></div>
<p dir="auto"></p>
</details>
<h1 dir="auto">Expected Behavior</h1>

<p dir="auto">Group1 get executed 1 time( 3 task)<br>
Group2 get executed 1 time( 3 task)<br>
Group3 get executed 1 time( 1 task)<br>
Group4 get executed 1 time( 1 task)</p>
<h1 dir="auto">Actual Behavior</h1>

<p dir="auto">Group1 get executed 1 time( 3 task)<br>
Group2 get executed 1 time( 3 task)<br>
Group3 get executed 3 times( 1 task)<br>
Group4 get executed 3 times( 1 task)</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" 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" 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"> 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" checked=""> 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"> 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><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="369051753" data-permission-text="Title is private" data-url="https://github.com/celery/celery/issues/5105" data-hovercard-type="issue" data-hovercard-url="/celery/celery/issues/5105/hovercard" href="https://github.com/celery/celery/issues/5105">#5105</a></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.4.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="not possible due to unit test context"><pre class="notranslate"><code class="notranslate">not possible due to unit test context
</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.6</li>
<li><strong>Minimal Celery Version</strong>: 4.4.0</li>
<li><strong>Minimal Kombu Version</strong>: N/A or Unknown</li>
<li><strong>Minimal Broker Version</strong>: N/A or Unknown</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>: 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==2.5.2
attrs==19.3.0
billiard==3.6.2.0
case==1.3.1
celery==4.4.0
importlib-metadata==1.5.0
kombu==4.6.7
linecache2==1.0.0
mock==4.0.1
more-itertools==8.2.0
nose==1.3.7
packaging==20.1
pluggy==0.13.1
py==1.8.1
pyparsing==2.4.6
pytest==5.3.5
pytest-mock==2.0.0
pytz==2019.3
six==1.14.0
traceback2==1.4.0
unittest2==1.1.0
vine==1.3.0
wcwidth==0.1.8
zipp==3.0.0"><pre class="notranslate"><code class="notranslate">amqp==2.5.2
attrs==19.3.0
billiard==3.6.2.0
case==1.3.1
celery==4.4.0
importlib-metadata==1.5.0
kombu==4.6.7
linecache2==1.0.0
mock==4.0.1
more-itertools==8.2.0
nose==1.3.7
packaging==20.1
pluggy==0.13.1
py==1.8.1
pyparsing==2.4.6
pytest==5.3.5
pytest-mock==2.0.0
pytz==2019.3
six==1.14.0
traceback2==1.4.0
unittest2==1.1.0
vine==1.3.0
wcwidth==0.1.8
zipp==3.0.0
</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>
<p dir="auto">Put this snippet into <code class="notranslate">t/test_tasks.py</code> and run it.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import pytest

@pytest.fixture
def celery_includes():
    return [
        't.unit.contrib.proj.foo'
    ]


def test_pytest_import_passes(celery_app, celery_worker):
    task = celery_app.send_task(&quot;t.unit.contrib.proj.foo.bar&quot;)
    task.get()


def test_pytest_second_with_new_app_fixtures_also_passes(celery_app, celery_worker):
    task = celery_app.send_task(&quot;t.unit.contrib.proj.foo.bar&quot;)
    task.get()"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">pytest</span>

<span class="pl-en">@<span class="pl-s1">pytest</span>.<span class="pl-s1">fixture</span></span>
<span class="pl-k">def</span> <span class="pl-en">celery_includes</span>():
    <span class="pl-k">return</span> [
        <span class="pl-s">'t.unit.contrib.proj.foo'</span>
    ]


<span class="pl-k">def</span> <span class="pl-en">test_pytest_import_passes</span>(<span class="pl-s1">celery_app</span>, <span class="pl-s1">celery_worker</span>):
    <span class="pl-s1">task</span> <span class="pl-c1">=</span> <span class="pl-s1">celery_app</span>.<span class="pl-en">send_task</span>(<span class="pl-s">"t.unit.contrib.proj.foo.bar"</span>)
    <span class="pl-s1">task</span>.<span class="pl-en">get</span>()


<span class="pl-k">def</span> <span class="pl-en">test_pytest_second_with_new_app_fixtures_also_passes</span>(<span class="pl-s1">celery_app</span>, <span class="pl-s1">celery_worker</span>):
    <span class="pl-s1">task</span> <span class="pl-c1">=</span> <span class="pl-s1">celery_app</span>.<span class="pl-en">send_task</span>(<span class="pl-s">"t.unit.contrib.proj.foo.bar"</span>)
    <span class="pl-s1">task</span>.<span class="pl-en">get</span>()</pre></div>
<p dir="auto">The second test case fails here.</p>
<p dir="auto"></p>

<h1 dir="auto">Expected Behavior</h1>
<p dir="auto">I can create two test cases that call the same task without hitting errors.</p>
<h1 dir="auto">Actual Behavior</h1>
<p dir="auto">The second test case always fails.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="tp = &lt;class 'celery.exceptions.NotRegistered'&gt;, value = Task of kind 't.unit.contrib.proj.foo.bar' never registered, please make sure it's imported., tb = None

    def reraise(tp, value, tb=None):
        &quot;&quot;&quot;Reraise exception.&quot;&quot;&quot;
        if value.__traceback__ is not tb:
            raise value.with_traceback(tb)
&gt;       raise value
E       celery.exceptions.NotRegistered: 't.unit.contrib.proj.foo.bar'

../../.local/share/virtualenvs/celery-R2pj-DTl/lib/python3.7/site-packages/vine/five.py:195: NotRegistered
---------------------------------------------------------------------- Captured log call ----------------------------------------------------------------------
ERROR    celery.worker.consumer.consumer:consumer.py:497 Received unregistered task of type 't.unit.contrib.proj.foo.bar'.
The message has been ignored and discarded.

Did you remember to import the module containing this task?
Or maybe you're using relative imports?

Please see
http://docs.celeryq.org/en/latest/internals/protocol.html
for more information.

The full contents of the message body was:
b'[[], {}, {&quot;callbacks&quot;: null, &quot;errbacks&quot;: null, &quot;chain&quot;: null, &quot;chord&quot;: null}]' (77b)
Traceback (most recent call last):
  File &quot;/Users/powerjo/.local/share/virtualenvs/celery-R2pj-DTl/lib/python3.7/site-packages/celery/worker/consumer/consumer.py&quot;, line 562, in on_task_received
    strategy = strategies[type_]
KeyError: 't.unit.contrib.proj.foo.bar'"><pre class="notranslate"><code class="notranslate">tp = &lt;class 'celery.exceptions.NotRegistered'&gt;, value = Task of kind 't.unit.contrib.proj.foo.bar' never registered, please make sure it's imported., tb = None

    def reraise(tp, value, tb=None):
        """Reraise exception."""
        if value.__traceback__ is not tb:
            raise value.with_traceback(tb)
&gt;       raise value
E       celery.exceptions.NotRegistered: 't.unit.contrib.proj.foo.bar'

../../.local/share/virtualenvs/celery-R2pj-DTl/lib/python3.7/site-packages/vine/five.py:195: NotRegistered
---------------------------------------------------------------------- Captured log call ----------------------------------------------------------------------
ERROR    celery.worker.consumer.consumer:consumer.py:497 Received unregistered task of type 't.unit.contrib.proj.foo.bar'.
The message has been ignored and discarded.

Did you remember to import the module containing this task?
Or maybe you're using relative imports?

Please see
http://docs.celeryq.org/en/latest/internals/protocol.html
for more information.

The full contents of the message body was:
b'[[], {}, {"callbacks": null, "errbacks": null, "chain": null, "chord": null}]' (77b)
Traceback (most recent call last):
  File "/Users/powerjo/.local/share/virtualenvs/celery-R2pj-DTl/lib/python3.7/site-packages/celery/worker/consumer/consumer.py", line 562, in on_task_received
    strategy = strategies[type_]
KeyError: 't.unit.contrib.proj.foo.bar'
</code></pre></div>