<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>[y] 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>[] 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><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="905564343" data-permission-text="Title is private" data-url="https://github.com/celery/celery/issues/6791" data-hovercard-type="pull_request" data-hovercard-url="/celery/celery/pull/6791/hovercard" href="https://github.com/celery/celery/pull/6791">#6791</a></li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="32051442" data-permission-text="Title is private" data-url="https://github.com/celery/celery/issues/1997" data-hovercard-type="issue" data-hovercard-url="/celery/celery/issues/1997/hovercard" href="https://github.com/celery/celery/issues/1997">#1997</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>:</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.1.2 (sun-harmonics) kombu:5.1.0 py:3.8.5
            billiard:3.6.4.0 redis:3.5.3
platform -&gt; system:Linux arch:64bit, ELF
            kernel version:5.8.0-59-generic imp:CPython
loader   -&gt; celery.loaders.app.AppLoader
settings -&gt; transport:redis results:disabled

broker_url: 'redis://localhost:6379/0'
deprecated_settings: None"><pre class="notranslate"><code class="notranslate">software -&gt; celery:5.1.2 (sun-harmonics) kombu:5.1.0 py:3.8.5
            billiard:3.6.4.0 redis:3.5.3
platform -&gt; system:Linux arch:64bit, ELF
            kernel version:5.8.0-59-generic imp:CPython
loader   -&gt; celery.loaders.app.AppLoader
settings -&gt; transport:redis results:disabled

broker_url: 'redis://localhost:6379/0'
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>: 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>: redis in docker</li>
<li><strong>Minimal Result Backend Version</strong>: N/A or Unknown</li>
<li><strong>Minimal OS and/or Kernel Version</strong>: Ubuntu 20.04</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
billiard==3.6.4.0
celery @ file:///tmp/x/celery
click==7.1.2
click-didyoumean==0.0.3
click-plugins==1.1.1
click-repl==0.2.0
kombu==5.1.0
prompt-toolkit==3.0.19
pytz==2021.1
redis==3.5.3
six==1.16.0
vine==5.0.0
wcwidth==0.2.5
"><pre class="notranslate"><code class="notranslate">amqp==5.0.6
billiard==3.6.4.0
celery @ file:///tmp/x/celery
click==7.1.2
click-didyoumean==0.0.3
click-plugins==1.1.1
click-repl==0.2.0
kombu==5.1.0
prompt-toolkit==3.0.19
pytz==2021.1
redis==3.5.3
six==1.16.0
vine==5.0.0
wcwidth==0.2.5

</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="from celery import Celery

app = Celery('tasks', broker='redis://localhost:6379/0')


@app.task
def f():
    print('hello hello world')

if __name__ == '__main__':
    f.apply_async()"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">celery</span> <span class="pl-k">import</span> <span class="pl-v">Celery</span>

<span class="pl-s1">app</span> <span class="pl-c1">=</span> <span class="pl-v">Celery</span>(<span class="pl-s">'tasks'</span>, <span class="pl-s1">broker</span><span class="pl-c1">=</span><span class="pl-s">'redis://localhost:6379/0'</span>)


<span class="pl-en">@<span class="pl-s1">app</span>.<span class="pl-s1">task</span></span>
<span class="pl-k">def</span> <span class="pl-en">f</span>():
    <span class="pl-en">print</span>(<span class="pl-s">'hello hello world'</span>)

<span class="pl-k">if</span> <span class="pl-s1">__name__</span> <span class="pl-c1">==</span> <span class="pl-s">'__main__'</span>:
    <span class="pl-s1">f</span>.<span class="pl-en">apply_async</span>()</pre></div>
<p dir="auto"></p>
</details>
<h1 dir="auto">Expected Behavior</h1>
<p dir="auto">only one line of output</p>

<div class="highlight highlight-text-shell-session notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content=" -------------- [queues]
                .&gt; celery           exchange=celery(direct) key=celery
                

[2021-06-30 19:28:02,606: WARNING/ForkPoolWorker-4] hello hello world"><pre class="notranslate"><span class="pl-c1"> -------------- [queues]</span>
<span class="pl-c1">                .&gt; celery           exchange=celery(direct) key=celery</span>
<span class="pl-c1">                </span>

<span class="pl-c1">[2021-06-30 19:28:02,606: WARNING/ForkPoolWorker-4] hello hello world</span></pre></div>
<h1 dir="auto">Actual Behavior</h1>
<p dir="auto">prints an empty line</p>
<div class="highlight highlight-text-shell-session notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content=" -------------- [queues]
                .&gt; celery           exchange=celery(direct) key=celery
                

[2021-06-30 19:28:02,606: WARNING/ForkPoolWorker-4] hello hello world
[2021-06-30 19:28:02,607: WARNING/ForkPoolWorker-4] "><pre class="notranslate"><span class="pl-c1"> -------------- [queues]</span>
<span class="pl-c1">                .&gt; celery           exchange=celery(direct) key=celery</span>
<span class="pl-c1">                </span>

<span class="pl-c1">[2021-06-30 19:28:02,606: WARNING/ForkPoolWorker-4] hello hello world</span>
<span class="pl-c1">[2021-06-30 19:28:02,607: WARNING/ForkPoolWorker-4] </span></pre></div>
<p dir="auto">when printing from the task function, each output causes a newline to be printed to <code class="notranslate">stderr</code>. This was introduced in version <code class="notranslate">5.1.*</code> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="905564343" data-permission-text="Title is private" data-url="https://github.com/celery/celery/issues/6791" data-hovercard-type="pull_request" data-hovercard-url="/celery/celery/pull/6791/hovercard" href="https://github.com/celery/celery/pull/6791">#6791</a> by removing this line: <a class="commit-link" href="https://github.com/celery/celery/commit/51f5b01df0434144521b23a35d16aebfee08c3ae#diff-116905b4c2ccc7e0172e26700ba1a0a0270b2fe1f830c47244dc1df07c805883L226"><tt>51f5b01</tt>#diff-116905b4c2ccc7e0172e26700ba1a0a0270b2fe1f830c47244dc1df07c805883L226</a></p>
<p dir="auto">I think there are different options how to address this:</p>
<ul dir="auto">
<li>just add the line back as it was -- but this would go against the initaly intention in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="905564343" data-permission-text="Title is private" data-url="https://github.com/celery/celery/issues/6791" data-hovercard-type="pull_request" data-hovercard-url="/celery/celery/pull/6791/hovercard" href="https://github.com/celery/celery/pull/6791">#6791</a> of removing it to don't do any string manipulation in this function</li>
<li>use something like <code class="notranslate">re.sub('\n|\r', '', data )</code> instead, to keep the whitespace or an endswith check or a more complex regex?</li>
<li>address this somewhere else, so no newline characters are passed to <code class="notranslate">.write()</code> (I would need a hint where to do this though)</li>
</ul>
<p dir="auto">I am happy to send a PR to fix this if needed.</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 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"> 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"> 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" checked=""> 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>
<h2 dir="auto">Related Issues and Possible Duplicates</h2>

<h4 dir="auto">Related Issues</h4>
<ul dir="auto">
<li>Subsequent groups within a chain fail <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="188895674" data-permission-text="Title is private" data-url="https://github.com/celery/celery/issues/3585" data-hovercard-type="issue" data-hovercard-url="/celery/celery/issues/3585/hovercard" href="https://github.com/celery/celery/issues/3585">#3585</a></li>
<li>Nested group(chain(group)) fails <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="439435258" data-permission-text="Title is private" data-url="https://github.com/celery/celery/issues/5496" data-hovercard-type="issue" data-hovercard-url="/celery/celery/issues/5496/hovercard" href="https://github.com/celery/celery/issues/5496">#5496</a></li>
<li>group([chain(group(task(), task()), group(...)), chain(group(...), group(...))]) construct never finishes <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="47837481" data-permission-text="Title is private" data-url="https://github.com/celery/celery/issues/2354" data-hovercard-type="issue" data-hovercard-url="/celery/celery/issues/2354/hovercard" href="https://github.com/celery/celery/issues/2354">#2354</a></li>
<li>Canvas with group-task-task-group does not work <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="413354133" data-permission-text="Title is private" data-url="https://github.com/celery/celery/issues/5354" data-hovercard-type="issue" data-hovercard-url="/celery/celery/issues/5354/hovercard" href="https://github.com/celery/celery/issues/5354">#5354</a></li>
</ul>
<h4 dir="auto">Possible Duplicates</h4>
<ul dir="auto">
<li>Nested group-chain-group structure never succeeds <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="68153195" data-permission-text="Title is private" data-url="https://github.com/celery/celery/issues/2573" data-hovercard-type="issue" data-hovercard-url="/celery/celery/issues/2573/hovercard" href="https://github.com/celery/celery/issues/2573">#2573</a></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:4.3.0 (rhubarb) kombu:4.5.0 py:3.6.5
            billiard:3.6.0.0 redis:3.2.1
platform -&gt; system:Linux arch:64bit
            kernel version:4.9.0-9-amd64 imp:CPython
loader   -&gt; celery.loaders.app.AppLoader
settings -&gt; transport:redis results:redis:///

broker_url: 'redis://localhost:6379//'
result_backend: 'redis:///'"><pre class="notranslate"><code class="notranslate">software -&gt; celery:4.3.0 (rhubarb) kombu:4.5.0 py:3.6.5
            billiard:3.6.0.0 redis:3.2.1
platform -&gt; system:Linux arch:64bit
            kernel version:4.9.0-9-amd64 imp:CPython
loader   -&gt; celery.loaders.app.AppLoader
settings -&gt; transport:redis results:redis:///

broker_url: 'redis://localhost:6379//'
result_backend: 'redis:///'
</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</li>
<li><strong>Minimal Celery Version</strong>: 4.3</li>
<li><strong>Minimal Kombu Version</strong>: 4.5.0</li>
<li><strong>Minimal Broker Version</strong>: N/A or Unknown</li>
<li><strong>Minimal Result Backend Version</strong>: Redis</li>
<li><strong>Minimal OS and/or Kernel Version</strong>: Debian Stretch</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.4.2
billiard==3.6.0.0
celery==4.3.0
celery-eternal==0.1.1
celery-singleton==0.1.3
certifi==2018.4.16
kombu==4.5.0
pytz==2019.1
redis==3.2.1
vine==1.3.0"><pre class="notranslate"><code class="notranslate">amqp==2.4.2
billiard==3.6.0.0
celery==4.3.0
celery-eternal==0.1.1
celery-singleton==0.1.3
certifi==2018.4.16
kombu==4.5.0
pytz==2019.1
redis==3.2.1
vine==1.3.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>

<details>
<p dir="auto">
</p><div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from time import sleep

from celery import Celery
from celery import group

app = Celery('tasks', broker = 'redis://')
app.conf['result_backend'] = app.conf.broker_url

@app.task
def prod(x, y):
    return x*y

@app.task
def subtract(args):
    return args[0]-args[1]

@app.task(shared=False)
def identity(args):
    &quot;&quot;&quot;Identity task (returns its input).&quot;&quot;&quot;
    return args

x = (
    group( prod.s(1, 1), prod.s(2, 1) )
    |
    identity.s()
    |
    subtract.s()
    |
    group( prod.s(5), prod.s(6) )
)
r = x.delay()
sleep(10)
print(r.waiting())

# Another case
x = (
    group( prod.s(1, 1), prod.s(2, 1) )
    |
    subtract.si((3,4))
    |
    subtract.si((4,3))
    |
    subtract.si((6,5))
    |
    group( prod.si(5, 6), prod.si(6, 5) )
)
r = x.delay()
sleep(10)
print(r.waiting())

# However this works
# x = (
#    group( prod.s(1, 1), prod.s(2, 1) )
#    |
#    subtract.si((3,4))
#    |
#    group( prod.si(5, 6), prod.si(6, 5) )
# )
# r = x.delay()
# print([p.result for p in r.results])
# prints [30, 30]

# The adding more than one component in between 2 groups
# in a chain is causing the canvas to wait right before the final group"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">time</span> <span class="pl-k">import</span> <span class="pl-s1">sleep</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>
<span class="pl-k">from</span> <span class="pl-s1">celery</span> <span class="pl-k">import</span> <span class="pl-s1">group</span>

<span class="pl-s1">app</span> <span class="pl-c1">=</span> <span class="pl-v">Celery</span>(<span class="pl-s">'tasks'</span>, <span class="pl-s1">broker</span> <span class="pl-c1">=</span> <span class="pl-s">'redis://'</span>)
<span class="pl-s1">app</span>.<span class="pl-s1">conf</span>[<span class="pl-s">'result_backend'</span>] <span class="pl-c1">=</span> <span class="pl-s1">app</span>.<span class="pl-s1">conf</span>.<span class="pl-s1">broker_url</span>

<span class="pl-en">@<span class="pl-s1">app</span>.<span class="pl-s1">task</span></span>
<span class="pl-k">def</span> <span class="pl-en">prod</span>(<span class="pl-s1">x</span>, <span class="pl-s1">y</span>):
    <span class="pl-k">return</span> <span class="pl-s1">x</span><span class="pl-c1">*</span><span class="pl-s1">y</span>

<span class="pl-en">@<span class="pl-s1">app</span>.<span class="pl-s1">task</span></span>
<span class="pl-k">def</span> <span class="pl-en">subtract</span>(<span class="pl-s1">args</span>):
    <span class="pl-k">return</span> <span class="pl-s1">args</span>[<span class="pl-c1">0</span>]<span class="pl-c1">-</span><span class="pl-s1">args</span>[<span class="pl-c1">1</span>]

<span class="pl-en">@<span class="pl-s1">app</span>.<span class="pl-en">task</span>(<span class="pl-s1">shared</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)</span>
<span class="pl-k">def</span> <span class="pl-en">identity</span>(<span class="pl-s1">args</span>):
    <span class="pl-s">"""Identity task (returns its input)."""</span>
    <span class="pl-k">return</span> <span class="pl-s1">args</span>

<span class="pl-s1">x</span> <span class="pl-c1">=</span> (
    <span class="pl-en">group</span>( <span class="pl-s1">prod</span>.<span class="pl-en">s</span>(<span class="pl-c1">1</span>, <span class="pl-c1">1</span>), <span class="pl-s1">prod</span>.<span class="pl-en">s</span>(<span class="pl-c1">2</span>, <span class="pl-c1">1</span>) )
    <span class="pl-c1">|</span>
    <span class="pl-s1">identity</span>.<span class="pl-en">s</span>()
    <span class="pl-c1">|</span>
    <span class="pl-s1">subtract</span>.<span class="pl-en">s</span>()
    <span class="pl-c1">|</span>
    <span class="pl-en">group</span>( <span class="pl-s1">prod</span>.<span class="pl-en">s</span>(<span class="pl-c1">5</span>), <span class="pl-s1">prod</span>.<span class="pl-en">s</span>(<span class="pl-c1">6</span>) )
)
<span class="pl-s1">r</span> <span class="pl-c1">=</span> <span class="pl-s1">x</span>.<span class="pl-en">delay</span>()
<span class="pl-en">sleep</span>(<span class="pl-c1">10</span>)
<span class="pl-en">print</span>(<span class="pl-s1">r</span>.<span class="pl-en">waiting</span>())

<span class="pl-c"># Another case</span>
<span class="pl-s1">x</span> <span class="pl-c1">=</span> (
    <span class="pl-en">group</span>( <span class="pl-s1">prod</span>.<span class="pl-en">s</span>(<span class="pl-c1">1</span>, <span class="pl-c1">1</span>), <span class="pl-s1">prod</span>.<span class="pl-en">s</span>(<span class="pl-c1">2</span>, <span class="pl-c1">1</span>) )
    <span class="pl-c1">|</span>
    <span class="pl-s1">subtract</span>.<span class="pl-en">si</span>((<span class="pl-c1">3</span>,<span class="pl-c1">4</span>))
    <span class="pl-c1">|</span>
    <span class="pl-s1">subtract</span>.<span class="pl-en">si</span>((<span class="pl-c1">4</span>,<span class="pl-c1">3</span>))
    <span class="pl-c1">|</span>
    <span class="pl-s1">subtract</span>.<span class="pl-en">si</span>((<span class="pl-c1">6</span>,<span class="pl-c1">5</span>))
    <span class="pl-c1">|</span>
    <span class="pl-en">group</span>( <span class="pl-s1">prod</span>.<span class="pl-en">si</span>(<span class="pl-c1">5</span>, <span class="pl-c1">6</span>), <span class="pl-s1">prod</span>.<span class="pl-en">si</span>(<span class="pl-c1">6</span>, <span class="pl-c1">5</span>) )
)
<span class="pl-s1">r</span> <span class="pl-c1">=</span> <span class="pl-s1">x</span>.<span class="pl-en">delay</span>()
<span class="pl-en">sleep</span>(<span class="pl-c1">10</span>)
<span class="pl-en">print</span>(<span class="pl-s1">r</span>.<span class="pl-en">waiting</span>())

<span class="pl-c"># However this works</span>
<span class="pl-c"># x = (</span>
<span class="pl-c">#    group( prod.s(1, 1), prod.s(2, 1) )</span>
<span class="pl-c">#    |</span>
<span class="pl-c">#    subtract.si((3,4))</span>
<span class="pl-c">#    |</span>
<span class="pl-c">#    group( prod.si(5, 6), prod.si(6, 5) )</span>
<span class="pl-c"># )</span>
<span class="pl-c"># r = x.delay()</span>
<span class="pl-c"># print([p.result for p in r.results])</span>
<span class="pl-c"># prints [30, 30]</span>

<span class="pl-c"># The adding more than one component in between 2 groups</span>
<span class="pl-c"># in a chain is causing the canvas to wait right before the final group</span></pre></div>
<p dir="auto"></p>
</details>
<h1 dir="auto">Expected Behavior</h1>

<p dir="auto">Above code snippet should return a list of 2 values<br>
([5, 6] in for first case, [30, 30] for second case)</p>
<h1 dir="auto">Actual Behavior</h1>
<p dir="auto">The code never never returns, keeps waiting</p>

<p dir="auto">Celery worker logs for the first case mentioned</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[2019-05-10 21:12:42,361: INFO/MainProcess] Connected to redis://localhost:6379//
[2019-05-10 21:12:42,366: INFO/MainProcess] mingle: searching for neighbors
[2019-05-10 21:12:43,380: INFO/MainProcess] mingle: all alone
[2019-05-10 21:12:43,393: INFO/MainProcess] celery@debian ready.
[2019-05-10 21:13:43,557: INFO/MainProcess] Received task: celery_task.prod[e11748a0-dca2-41fb-b799-a2ae7879c9fd]  
[2019-05-10 21:13:43,559: INFO/MainProcess] Received task: celery_task.prod[6ec1c88f-cca7-417c-8ff1-eacd9bdef7a1]  
[2019-05-10 21:13:43,566: INFO/ForkPoolWorker-2] Task celery_task.prod[6ec1c88f-cca7-417c-8ff1-eacd9bdef7a1] succeeded in 0.0064055299990286585s: 2
[2019-05-10 21:13:43,585: INFO/ForkPoolWorker-1] Task celery_task.prod[e11748a0-dca2-41fb-b799-a2ae7879c9fd] succeeded in 0.02549504399939906s: 1
[2019-05-10 21:13:43,586: INFO/MainProcess] Received task: celery_task.identity[87148533-8da1-4fc6-bbfe-608470cb3c1a]  
[2019-05-10 21:13:43,588: INFO/ForkPoolWorker-1] Task celery_task.identity[87148533-8da1-4fc6-bbfe-608470cb3c1a] succeeded in 0.0011925399994652253s: [2, 1]
[2019-05-10 21:13:43,588: INFO/MainProcess] Received task: celery_task.subtract[e907af43-a886-45ea-bfe3-f709c8267e5d]  
[2019-05-10 21:13:43,589: INFO/ForkPoolWorker-1] Task celery_task.subtract[e907af43-a886-45ea-bfe3-f709c8267e5d] succeeded in 0.00028916799965372775s: 1"><pre class="notranslate"><code class="notranslate">[2019-05-10 21:12:42,361: INFO/MainProcess] Connected to redis://localhost:6379//
[2019-05-10 21:12:42,366: INFO/MainProcess] mingle: searching for neighbors
[2019-05-10 21:12:43,380: INFO/MainProcess] mingle: all alone
[2019-05-10 21:12:43,393: INFO/MainProcess] celery@debian ready.
[2019-05-10 21:13:43,557: INFO/MainProcess] Received task: celery_task.prod[e11748a0-dca2-41fb-b799-a2ae7879c9fd]  
[2019-05-10 21:13:43,559: INFO/MainProcess] Received task: celery_task.prod[6ec1c88f-cca7-417c-8ff1-eacd9bdef7a1]  
[2019-05-10 21:13:43,566: INFO/ForkPoolWorker-2] Task celery_task.prod[6ec1c88f-cca7-417c-8ff1-eacd9bdef7a1] succeeded in 0.0064055299990286585s: 2
[2019-05-10 21:13:43,585: INFO/ForkPoolWorker-1] Task celery_task.prod[e11748a0-dca2-41fb-b799-a2ae7879c9fd] succeeded in 0.02549504399939906s: 1
[2019-05-10 21:13:43,586: INFO/MainProcess] Received task: celery_task.identity[87148533-8da1-4fc6-bbfe-608470cb3c1a]  
[2019-05-10 21:13:43,588: INFO/ForkPoolWorker-1] Task celery_task.identity[87148533-8da1-4fc6-bbfe-608470cb3c1a] succeeded in 0.0011925399994652253s: [2, 1]
[2019-05-10 21:13:43,588: INFO/MainProcess] Received task: celery_task.subtract[e907af43-a886-45ea-bfe3-f709c8267e5d]  
[2019-05-10 21:13:43,589: INFO/ForkPoolWorker-1] Task celery_task.subtract[e907af43-a886-45ea-bfe3-f709c8267e5d] succeeded in 0.00028916799965372775s: 1
</code></pre></div>
<p dir="auto">Considering the first case mentioned in the code snippet, you can see that value of the task before the second group, <code class="notranslate">subtract</code>, is returned but the last group (consisting 2 <code class="notranslate">prod</code>s) is never received, even after waiting many minutes. (I put the <code class="notranslate">sleep(10)</code> just as a proxy for some wait)</p>