<h2 dir="auto">Checklist</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>
</ul>
<h2 dir="auto">Report</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="software -&gt; celery:4.0.2 (latentcall) kombu:4.0.2 py:3.5.0
            billiard:3.5.0.2 py-amqp:2.1.4
platform -&gt; system:Darwin arch:64bit imp:CPython
loader   -&gt; celery.loaders.app.AppLoader
settings -&gt; transport:amqp results:rpc

imports:
    ('project.myapp.tasks',)
task_annotations: {
 'tasks.add': {'rate_limit': '10/s'}}
broker_url: 'amqp://guest:********@localhost:5672//'
result_backend: 'rpc'"><pre class="notranslate"><code class="notranslate">software -&gt; celery:4.0.2 (latentcall) kombu:4.0.2 py:3.5.0
            billiard:3.5.0.2 py-amqp:2.1.4
platform -&gt; system:Darwin arch:64bit imp:CPython
loader   -&gt; celery.loaders.app.AppLoader
settings -&gt; transport:amqp results:rpc

imports:
    ('project.myapp.tasks',)
task_annotations: {
 'tasks.add': {'rate_limit': '10/s'}}
broker_url: 'amqp://guest:********@localhost:5672//'
result_backend: 'rpc'
</code></pre></div>
<h2 dir="auto">Steps to reproduce</h2>
<ol dir="auto">
<li>Start default <code class="notranslate">rabbitmq-server</code> and a default <code class="notranslate">worker</code></li>
<li>Have two tasks, one called inside the other:</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="@celery_app.task
def super_task():
    async_res = sub_task.apply_async()
    while not async_res.ready():
        time.sleep(1)

    if async_res.failed():
        raise async_res.result
    else:
        return async_res.result


@celery_app.task
def sub_task():
    raise Exception('Controlled error')"><pre class="notranslate"><code class="notranslate">@celery_app.task
def super_task():
    async_res = sub_task.apply_async()
    while not async_res.ready():
        time.sleep(1)

    if async_res.failed():
        raise async_res.result
    else:
        return async_res.result


@celery_app.task
def sub_task():
    raise Exception('Controlled error')
</code></pre></div>
<ol start="3" dir="auto">
<li>Call for <code class="notranslate">super_task</code></li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="r = super_task.apply_async()

    try:
        r.get()
    except Exception as exc:
        if exc.__class__.__module__ != 'builtins':
            assert 0, 'Exception type is not builtin'"><pre class="notranslate"><code class="notranslate">r = super_task.apply_async()

    try:
        r.get()
    except Exception as exc:
        if exc.__class__.__module__ != 'builtins':
            assert 0, 'Exception type is not builtin'
</code></pre></div>
<p dir="auto"><em>optionally</em>: download the attached project, install celery and run the file <code class="notranslate">test_raising.py</code><br>
<a href="https://github.com/celery/celery/files/702053/celery_project.zip">celery_project.zip</a></p>
<h2 dir="auto">Expected behavior</h2>
<p dir="auto">The subtask exception of type <code class="notranslate">Exception</code> from python <code class="notranslate">builtins</code> module to be arisen up to the main process and the assert check successful</p>
<h2 dir="auto">Actual behavior</h2>
<p dir="auto">The arisen exception is not builtin is of class <code class="notranslate">celery.backends.base.Exception</code> instead, and if you check the <code class="notranslate">worker</code> log a <code class="notranslate">super_task</code> task handler raised an error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;MaybeEncodingError: Error sending result: '&quot;(1, &lt;ExceptionInfo: Exception('Controlled error',)&gt;, None)&quot;'. Reason: ''PicklingError(&quot;Can\'t pickle &lt;class \'celery.backends.base.Exception\'&gt;: attribute lookup Exception on celery.backends.base failed&quot;,)''.&gt;"><pre class="notranslate"><code class="notranslate">&lt;MaybeEncodingError: Error sending result: '"(1, &lt;ExceptionInfo: Exception('Controlled error',)&gt;, None)"'. Reason: ''PicklingError("Can\'t pickle &lt;class \'celery.backends.base.Exception\'&gt;: attribute lookup Exception on celery.backends.base failed",)''.&gt;
</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>[] 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" 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" checked=""> 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" checked=""> 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" checked=""> 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" 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" 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.4.0</p>

<details>
<summary><b><code class="notranslate">celery report</code> Output:</b></summary>
<p dir="auto">
</p><p dir="auto">keep having <code class="notranslate">celery: error: unrecognized arguments: report</code><br>
but the error is in when calling to celery and not from celery it self</p>
<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.1</li>
<li><strong>Minimal Celery Version</strong>: 4.4.0</li>
<li><strong>Minimal Kombu Version</strong>: 4.6.7</li>
<li><strong>Minimal Broker Version</strong>: 3.8.3</li>
<li><strong>Minimal Result Backend Version</strong>: 5.0.3</li>
<li><strong>Minimal OS and/or Kernel Version</strong>: Mac 10.14.6</li>
<li><strong>Minimal Broker Client Version</strong>: 3.3.11</li>
<li><strong>Minimal Result Backend Client Version</strong>: 3.3.11</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="kombu==4.6.7
amqp==2.5.2
celery==4.4.0
redis==3.3.11"><pre class="notranslate"><code class="notranslate">kombu==4.6.7
amqp==2.5.2
celery==4.4.0
redis==3.3.11
</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><p dir="auto">Its not a test case but please run the python file here<br>
<a href="https://gist.github.com/ericman93/2ec31270ea68b3cfd56338039c766e9c">https://gist.github.com/ericman93/2ec31270ea68b3cfd56338039c766e9c</a></p>
<p dir="auto"></p>
</details>
<h1 dir="auto">Expected Behavior</h1>
<p dir="auto">Taks to run</p>
<h1 dir="auto">Actual Behavior</h1>
<p dir="auto">Trying to run this pipeline</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="eric.celery.core.print_message('START!') | %(dummy([print_message('Starting subtask A'), eric.celery.tasks.change_project_status_task('ad56c520f9a74173ad3e6446f19712b8', 'Subtask A')]) | %(dummy([print_message('Starting Subtask B'), eric.tasks.change_project_status_task('ad56c520f9a74173ad3e6446f19712b8', 'Subtask B'), eric.tasks.subtask_b('ad56c520f9a74173ad3e6446f19712b8', '458db63427bd48e98f9b3d27204589a9', 2, '946f464babca43de8bc03e5c1202f813')]) | %(dummy([print_message('Starting Subtask C'), eric.tasks.change_project_status_task('ad56c520f9a74173ad3e6446f19712b8', 'Subtask C'), eric.tasks.subtask_c('ad56c520f9a74173ad3e6446f19712b8', 'C')]) | print_message('Starting next session') | %(dummy([%(dummy([print_message('Starting subtask D-I'), eric.tasks.change_project_status_task('ad56c520f9a74173ad3e6446f19712b8', 'Subtask D'), eric.tasks.subtask_d('974fb9cb12e04a3a856c4438b5bb33b7')]) | %dummy([print_message('Starting Subtask D-I'), eric.tasks.change_project_status_task('ad56c520f9a74173ad3e6446f19712b8', 'Subtask E'), eric.tasks.subtask_e('aa107a89e6d84aa1999269725f5a6b11', 2), eric.tasks.subtask_e('ce2d6f8dc6494222979b00582f75a0eb', 2), eric.tasks.subtask_e('35d2c5f0d04a4c7cb48751ddec3e469d', 2), eric.tasks.subtask_e('410318c5579046cdbf009be243e4596c', 2)])), %(dummy([print_message('Starting subtask D-II'), eric.tasks.change_project_status_task('ad56c520f9a74173ad3e6446f19712b8', 'Subtask D'), eric.tasks.subtask_d('0cd1a4cd01774644aa9ee8cc1fbac834')]) | %dummy([print_message('Starting Subtask E-II'), eric.tasks.change_project_status_task('ad56c520f9a74173ad3e6446f19712b8', 'Subtask E'), eric.tasks.subtask_e('c6d0947ac9214d68a1b3ef889a2fe2b2', 2), eric.tasks.subtask_e('81a7e39833e54fdcba9dbe0590354954', 2), eric.tasks.subtask_e('38f80253760c4f8d8747e667dfc90914', 2), eric.tasks.subtask_e('5249d50e4c0342e8abe3d343f9998361', 2)]))]) | %(dummy([print_message('Staring subtask F'), eric.tasks.change_project_status_task('ad56c520f9a74173ad3e6446f19712b8', 'Subtask F'), eric.tasks.subtask_f('ad56c520f9a74173ad3e6446f19712b8')]) | %(dummy([print_message('Starting subtask G'), eric.tasks.change_project_status_task('ad56c520f9a74173ad3e6446f19712b8', 'Subtask G'), eric.tasks.subtask_g_1('ad56c520f9a74173ad3e6446f19712b8'), eric.tasks.subtask_g_2('ad56c520f9a74173ad3e6446f19712b8')]) | %dummy([print_message('Final sub task'), eric.tasks.change_project_status_task('ad56c520f9a74173ad3e6446f19712b8', 'Complete'), eric.tasks.finish_1('ad56c520f9a74173ad3e6446f19712b8'), eric.tasks.finish_2('ad56c520f9a74173ad3e6446f19712b8')])))))))"><pre class="notranslate"><code class="notranslate">eric.celery.core.print_message('START!') | %(dummy([print_message('Starting subtask A'), eric.celery.tasks.change_project_status_task('ad56c520f9a74173ad3e6446f19712b8', 'Subtask A')]) | %(dummy([print_message('Starting Subtask B'), eric.tasks.change_project_status_task('ad56c520f9a74173ad3e6446f19712b8', 'Subtask B'), eric.tasks.subtask_b('ad56c520f9a74173ad3e6446f19712b8', '458db63427bd48e98f9b3d27204589a9', 2, '946f464babca43de8bc03e5c1202f813')]) | %(dummy([print_message('Starting Subtask C'), eric.tasks.change_project_status_task('ad56c520f9a74173ad3e6446f19712b8', 'Subtask C'), eric.tasks.subtask_c('ad56c520f9a74173ad3e6446f19712b8', 'C')]) | print_message('Starting next session') | %(dummy([%(dummy([print_message('Starting subtask D-I'), eric.tasks.change_project_status_task('ad56c520f9a74173ad3e6446f19712b8', 'Subtask D'), eric.tasks.subtask_d('974fb9cb12e04a3a856c4438b5bb33b7')]) | %dummy([print_message('Starting Subtask D-I'), eric.tasks.change_project_status_task('ad56c520f9a74173ad3e6446f19712b8', 'Subtask E'), eric.tasks.subtask_e('aa107a89e6d84aa1999269725f5a6b11', 2), eric.tasks.subtask_e('ce2d6f8dc6494222979b00582f75a0eb', 2), eric.tasks.subtask_e('35d2c5f0d04a4c7cb48751ddec3e469d', 2), eric.tasks.subtask_e('410318c5579046cdbf009be243e4596c', 2)])), %(dummy([print_message('Starting subtask D-II'), eric.tasks.change_project_status_task('ad56c520f9a74173ad3e6446f19712b8', 'Subtask D'), eric.tasks.subtask_d('0cd1a4cd01774644aa9ee8cc1fbac834')]) | %dummy([print_message('Starting Subtask E-II'), eric.tasks.change_project_status_task('ad56c520f9a74173ad3e6446f19712b8', 'Subtask E'), eric.tasks.subtask_e('c6d0947ac9214d68a1b3ef889a2fe2b2', 2), eric.tasks.subtask_e('81a7e39833e54fdcba9dbe0590354954', 2), eric.tasks.subtask_e('38f80253760c4f8d8747e667dfc90914', 2), eric.tasks.subtask_e('5249d50e4c0342e8abe3d343f9998361', 2)]))]) | %(dummy([print_message('Staring subtask F'), eric.tasks.change_project_status_task('ad56c520f9a74173ad3e6446f19712b8', 'Subtask F'), eric.tasks.subtask_f('ad56c520f9a74173ad3e6446f19712b8')]) | %(dummy([print_message('Starting subtask G'), eric.tasks.change_project_status_task('ad56c520f9a74173ad3e6446f19712b8', 'Subtask G'), eric.tasks.subtask_g_1('ad56c520f9a74173ad3e6446f19712b8'), eric.tasks.subtask_g_2('ad56c520f9a74173ad3e6446f19712b8')]) | %dummy([print_message('Final sub task'), eric.tasks.change_project_status_task('ad56c520f9a74173ad3e6446f19712b8', 'Complete'), eric.tasks.finish_1('ad56c520f9a74173ad3e6446f19712b8'), eric.tasks.finish_2('ad56c520f9a74173ad3e6446f19712b8')])))))))
</code></pre></div>
<p dir="auto">When using Rabbit as a broker it tasks 20 seconds to run <code class="notranslate">applay_async</code> and then the tasks are not starting in celery.<br>
When using Redis as a broker this exception raising</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;/Users/eric/.local/share/virtualenvs/romee-vHL_yubm/lib/python3.6/site-packages/redis/connection.py&quot;, line 666, in send_packed_command
    sendall(self._sock, item)
  File &quot;/Users/eric/.local/share/virtualenvs/romee-vHL_yubm/lib/python3.6/site-packages/redis/_compat.py&quot;, line 8, in sendall
    return sock.sendall(*args, **kwargs)
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File &quot;/Users/eric/.local/share/virtualenvs/romee-vHL_yubm/lib/python3.6/site-packages/kombu/connection.py&quot;, line 439, in _reraise_as_library_errors
    yield
  File &quot;/Users/eric/.local/share/virtualenvs/romee-vHL_yubm/lib/python3.6/site-packages/kombu/connection.py&quot;, line 518, in _ensured
    return fun(*args, **kwargs)
  File &quot;/Users/eric/.local/share/virtualenvs/romee-vHL_yubm/lib/python3.6/site-packages/kombu/messaging.py&quot;, line 203, in _publish
    mandatory=mandatory, immediate=immediate,
  File &quot;/Users/eric/.local/share/virtualenvs/romee-vHL_yubm/lib/python3.6/site-packages/kombu/transport/virtual/base.py&quot;, line 608, in basic_publish
    return self._put(routing_key, message, **kwargs)
  File &quot;/Users/eric/.local/share/virtualenvs/romee-vHL_yubm/lib/python3.6/site-packages/kombu/transport/redis.py&quot;, line 789, in _put
    client.lpush(self._q_for_pri(queue, pri), dumps(message))
  File &quot;/Users/eric/.local/share/virtualenvs/romee-vHL_yubm/lib/python3.6/site-packages/redis/client.py&quot;, line 1679, in lpush
    return self.execute_command('LPUSH', name, *values)
  File &quot;/Users/eric/.local/share/virtualenvs/romee-vHL_yubm/lib/python3.6/site-packages/redis/client.py&quot;, line 838, in execute_command
    conn.send_command(*args)
  File &quot;/Users/eric/.local/share/virtualenvs/romee-vHL_yubm/lib/python3.6/site-packages/redis/connection.py&quot;, line 687, in send_command
    check_health=kwargs.get('check_health', True))
  File &quot;/Users/eric/.local/share/virtualenvs/romee-vHL_yubm/lib/python3.6/site-packages/redis/connection.py&quot;, line 679, in send_packed_command
    (errno, errmsg))
redis.exceptions.ConnectionError: Error 32 while writing to socket. Broken pipe."><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "/Users/eric/.local/share/virtualenvs/romee-vHL_yubm/lib/python3.6/site-packages/redis/connection.py", line 666, in send_packed_command
    sendall(self._sock, item)
  File "/Users/eric/.local/share/virtualenvs/romee-vHL_yubm/lib/python3.6/site-packages/redis/_compat.py", line 8, in sendall
    return sock.sendall(*args, **kwargs)
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/eric/.local/share/virtualenvs/romee-vHL_yubm/lib/python3.6/site-packages/kombu/connection.py", line 439, in _reraise_as_library_errors
    yield
  File "/Users/eric/.local/share/virtualenvs/romee-vHL_yubm/lib/python3.6/site-packages/kombu/connection.py", line 518, in _ensured
    return fun(*args, **kwargs)
  File "/Users/eric/.local/share/virtualenvs/romee-vHL_yubm/lib/python3.6/site-packages/kombu/messaging.py", line 203, in _publish
    mandatory=mandatory, immediate=immediate,
  File "/Users/eric/.local/share/virtualenvs/romee-vHL_yubm/lib/python3.6/site-packages/kombu/transport/virtual/base.py", line 608, in basic_publish
    return self._put(routing_key, message, **kwargs)
  File "/Users/eric/.local/share/virtualenvs/romee-vHL_yubm/lib/python3.6/site-packages/kombu/transport/redis.py", line 789, in _put
    client.lpush(self._q_for_pri(queue, pri), dumps(message))
  File "/Users/eric/.local/share/virtualenvs/romee-vHL_yubm/lib/python3.6/site-packages/redis/client.py", line 1679, in lpush
    return self.execute_command('LPUSH', name, *values)
  File "/Users/eric/.local/share/virtualenvs/romee-vHL_yubm/lib/python3.6/site-packages/redis/client.py", line 838, in execute_command
    conn.send_command(*args)
  File "/Users/eric/.local/share/virtualenvs/romee-vHL_yubm/lib/python3.6/site-packages/redis/connection.py", line 687, in send_command
    check_health=kwargs.get('check_health', True))
  File "/Users/eric/.local/share/virtualenvs/romee-vHL_yubm/lib/python3.6/site-packages/redis/connection.py", line 679, in send_packed_command
    (errno, errmsg))
redis.exceptions.ConnectionError: Error 32 while writing to socket. Broken pipe.
</code></pre></div>
<p dir="auto">This is really gets stuck at <code class="notranslate">producer.publish</code> in <code class="notranslate">amqp.py</code><br>
If I make the pipeline smaller, everthing works fine</p>