Issue 1:
Configuration

Django 1.3.1 non-rel

celery==3.0.19

django-celery==3.0.17

celery-haystack==0.7.2

Log from celery server

-------------- celery@laptop v3.0.19 (Chiastic Slide)

---- **** -----

--- * *** * -- Windows-7-6.1.7601-SP1

-- * - **** ---

** ---------- [config]

** ---------- .> broker: redis://127.0.0.1:6379/0

** ---------- .> app: default:0x2b07d70 (djcelery.loaders.DjangoLoader)

** ---------- .> concurrency: 4 (processes)

*** --- * --- .> events: ON

-- ******* ----

--- ***** ----- [queues]

-------------- .> celery: exchange:celery(direct) binding:celery

[Tasks]

. celery.backend_cleanup

. celery.chain

. celery.chord

. celery.chord_unlock

. celery.chunks

. celery.group

. celery.map

. celery.starmap

. celery_haystack.tasks.CeleryHaystackSignalHandler

. celery_haystack.tasks.CeleryHaystackUpdateIndex

......

......

....

[2013-06-12 00:11:10,713: INFO/MainProcess] Got task from broker: celery_haystack.tasks.CeleryHaysta

[2013-06-12 00:11:10,733: DEBUG/MainProcess] Mediator: Running callback for task: celery_haystack.ta

[2013-06-12 00:11:10,733: DEBUG/MainProcess] TaskPool: Apply <function _fast_trace_task at 0x0408C6B

[2013-06-12 00:11:10,737: DEBUG/MainProcess] Task accepted: celery_haystack.tasks.CeleryHaystackSign

[2013-06-12 00:11:10,846: ERROR/MainProcess] Task celery_haystack.tasks.CeleryHaystackSignalHandler[

Traceback (most recent call last):

File "C:\Python27\lib\site-packages\billiard\pool.py", line 313, in worker

result = (True, func(_args, *_kwds))

File "C:\Python27\lib\site-packages\celery\task\trace.py", line 320, in _fast_trace_task

return _tasks[task].trace(uuid, args, kwargs, request)[0]

File "C:\Python27\lib\site-packages\celery\app\registry.py", line 20, in missing

raise self.NotRegistered(key)

NotRegistered: 'celery_haystack.tasks.CeleryHaystackSignalHandler'

Issue 2:
Checklist

I have read the relevant section in the

contribution guide

on reporting bugs.

I have checked the issues list

for similar or identical bug reports.

I have checked the pull requests list

for existing proposed fixes.

I have checked the commit log

to find out if the bug was already fixed in the master branch.

I have included all related issues and possible duplicate issues

in this issue (If there are none, check this box anyway).

Mandatory Debugging Information

I have included the output of celery -A proj report in the issue.

(if you are not able to do this, then at least specify the Celery

version affected).

I have verified that the issue exists against the master branch of Celery.

I have included the contents of pip freeze in the issue.

I have included all the versions of all the external dependencies required

to reproduce this bug.

Optional Debugging Information

I have tried reproducing the issue on more than one Python version

and/or implementation.

I have tried reproducing the issue on more than one message broker and/or

result backend.

I have tried reproducing the issue on more than one version of the message

broker and/or result backend.

I have tried reproducing the issue on more than one operating system.

I have tried reproducing the issue on more than one workers pool.

I have tried reproducing the issue with autoscaling, retries,

ETA/Countdown & rate limits disabled.

I have tried reproducing the issue after downgrading

and/or upgrading Celery and its dependencies.

Related Issues and Possible Duplicates

Related Issues

#3586

Possible Duplicates

#3586

Environment & Settings

Celery version:

celery report Output:

software -> celery:4.4.0rc2 (cliffs) kombu:4.6.3 py:3.6.7
billiard:3.6.0.0 py-amqp:2.5.0
platform -> system:Linux arch:64bit
kernel version:4.9.125-linuxkit imp:CPython
loader -> celery.loaders.app.AppLoader
settings -> transport:pyamqp results:redis://redis/

broker_url: 'amqp://guest:********@rabbit:5672//'
result_backend: 'redis://redis/'

Steps to Reproduce

Required Dependencies

Minimal Python Version: N/A or Unknown

Minimal Celery Version: N/A or Unknown

Minimal Kombu Version: N/A or Unknown

Minimal Broker Version: N/A or Unknown

Minimal Result Backend Version: N/A or Unknown

Minimal OS and/or Kernel Version: N/A or Unknown

Minimal Broker Client Version: N/A or Unknown

Minimal Result Backend Client Version: N/A or Unknown

Python Packages

pip freeze Output:

alabaster==0.7.12
amqp==2.5.0
asn1crypto==0.24.0
aspy.yaml==1.3.0
atomicwrites==1.3.0
attrs==19.1.0
aws-xray-sdk==0.95
azure-common==1.1.5
azure-nspkg==3.0.2
azure-storage==0.36.0
azure-storage-common==1.1.0
azure-storage-nspkg==3.1.0
Babel==2.7.0
basho-erlastic==2.1.1
billiard==3.6.0.0
boto==2.49.0
boto3==1.9.180
botocore==1.12.180
bumpversion==0.5.3
case==1.5.3
cassandra-driver==3.18.0
celery==4.4.0rc2
certifi==2019.6.16
cffi==1.12.3
cfgv==2.0.0
chardet==3.0.4
codecov==2.0.15
couchbase==2.5.5
coverage==4.5.3
cryptography==2.7
DateTime==4.3
dnspython==1.16.0
docker==4.0.2
docutils==0.14
ecdsa==0.13.2
elasticsearch==7.0.2
entrypoints==0.3
ephem==3.7.6.0
eventlet==0.25.0
filelock==3.0.12
flake8==3.7.7
flakeplus==1.1.0
future==0.17.1
gevent==1.4.0
greenlet==0.4.15
identify==1.4.5
idna==2.8
imagesize==1.1.0
importlib-metadata==0.18
importlib-resources==1.0.2
Jinja2==2.10.1
jmespath==0.9.4
jsondiff==1.1.1
jsonpickle==1.2
kombu==4.6.3
linecache2==1.0.0
MarkupSafe==1.1.1
mccabe==0.6.1
mock==3.0.5
monotonic==1.5
more-itertools==7.1.0
moto==1.3.7
msgpack==0.6.1
nodeenv==1.3.3
nose==1.3.7
packaging==19.0
pluggy==0.12.0
pre-commit==1.17.0
py==1.8.0
pyaml==19.4.1
pyArango==1.3.2
pycodestyle==2.5.0
pycouchdb==1.14
pycparser==2.19
pycryptodome==3.8.2
pycurl==7.43.0.3
pydocstyle==1.1.1
pydocumentdb==2.3.2
pyflakes==2.1.1
Pygments==2.4.2
pylibmc==1.6.0
pymongo==3.8.0
pyparsing==2.4.0
pytest==4.6.4
pytest-cov==2.7.1
pytest-sugar==0.9.2
pytest-travis-fold==1.3.0
python-consul==1.1.0
python-dateutil==2.8.0
python-jose==2.0.2
python-memcached==1.59
python3-protobuf==2.5.0
pytz==2019.1
PyYAML==5.1.1
redis==3.2.1
requests==2.22.0
responses==0.10.6
riak==2.7.0
s3transfer==0.2.1
simplejson==3.16.0
six==1.12.0
snowballstemmer==1.9.0
softlayer-messaging==1.0.3
Sphinx==1.8.5
sphinx-celery==1.4.6
sphinx-testing==0.7.2
sphinx2rst==1.1.0
sphinxcontrib-websupport==1.1.2
SQLAlchemy==1.3.5
tblib==1.4.0
tenacity==5.0.4
termcolor==1.1.0
toml==0.10.0
tox==3.13.1
traceback2==1.4.0
typing==3.7.4
Unipath==1.1
unittest2==1.1.0
urllib3==1.25.3
vine==1.3.0
virtualenv==16.6.1
wcwidth==0.1.7
websocket-client==0.56.0
Werkzeug==0.15.4
wrapt==1.11.2
xmltodict==0.12.0
zipp==0.5.1
zope.interface==4.6.0

Other Dependencies

N/A

Minimally Reproducible Test Case

from celery import Celery
from tenacity import retry, stop_after_attempt, wait_fixed

app = Celery('tasks', broker='pyamqp://rabbit:5672', backend='redis://redis/')

@retry(reraise=False, stop=stop_after_attempt(2), wait=wait_fixed(1))
def foo(x):
print('attempt foo')
raise ValueError('this is value error')

@app.task
def add(x, y):
foo(x)
return x + y

Expected Behavior

Running the add task should result in the following output

attempt foo
attempt foo
Traceback (most recent call last):
File "/home/developer/.pyenv/versions/python3.6/lib/python3.6/site-packages/tenacity/__init__.py", line 361, in call
result = fn(*args, **kwargs)
File "/home/developer/celery/tasks.py", line 15, in foo
foo(x)
ValueError: this is value error

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/developer/celery/celery/local.py", line 191, in __call__
return self._get_current_object()(*a, **kw)
File "/home/developer/celery/celery/app/task.py", line 400, in __call__
return self.run(*args, **kwargs)
File "/home/developer/celery/tasks.py", line 21, in add
File "/home/developer/.pyenv/versions/python3.6/lib/python3.6/site-packages/tenacity/__init__.py", line 292, in wrapped_f
return self.call(f, *args, **kw)
File "/home/developer/.pyenv/versions/python3.6/lib/python3.6/site-packages/tenacity/__init__.py", line 358, in call
do = self.iter(retry_state=retry_state)
File "/home/developer/.pyenv/versions/python3.6/lib/python3.6/site-packages/tenacity/__init__.py", line 332, in iter
six.raise_from(retry_exc, fut.exception())
File "<string>", line 3, in raise_from
tenacity.RetryError: RetryError[<Future at 0x7fe83b4c4240 state=finished raised ValueError>]

Actual Behavior

Instead, it fails to serialize the exception

[2019-07-01 17:47:12,837: WARNING/ForkPoolWorker-1] attempt foo
[2019-07-01 17:47:13,846: WARNING/ForkPoolWorker-1] attempt foo
[2019-07-01 17:47:13,866: ERROR/ForkPoolWorker-1] Task tasks.add[f303fe29-11fe-4da6-aed4-97648b0c27d1] raised unexpected: RetryError('<Future at 0x7fdf2212b710 state=finished raised ValueError>',)
Traceback (most recent call last):
File "/home/developer/celery/celery/app/trace.py", line 385, in trace_task
R = retval = fun(*args, **kwargs)
File "/home/developer/celery/celery/app/trace.py", line 650, in __protected_call__
return self.run(*args, **kwargs)
File "/home/developer/celery/tasks.py", line 21, in add
foo(x)
File "/home/developer/.pyenv/versions/python3.6/lib/python3.6/site-packages/tenacity/__init__.py", line 292, in wrapped_f
return self.call(f, *args, **kw)
File "/home/developer/.pyenv/versions/python3.6/lib/python3.6/site-packages/tenacity/__init__.py", line 358, in call
do = self.iter(retry_state=retry_state)
File "/home/developer/.pyenv/versions/python3.6/lib/python3.6/site-packages/tenacity/__init__.py", line 332, in iter
six.raise_from(retry_exc, fut.exception())
File "<string>", line 3, in raise_from
tenacity.RetryError: <Future at 0x7fdf2212b710 state=finished raised ValueError>
[2019-07-01 17:47:13,880: ERROR/MainProcess] Task handler raised error: <MaybeEncodingError: Error sending result: '"(1, <ExceptionInfo: RetryError('<Future at 0x7fdf2212b710 state=finished raised ValueError>',)>, None)"'. Reason: ''PicklingError("Can\'t pickle <class \'tenacity.RetryError\'>: it\'s not the same object as tenacity.RetryError",)''.>
Traceback (most recent call last):
File "/home/developer/.pyenv/versions/python3.6/lib/python3.6/site-packages/billiard/pool.py", line 362, in workloop
put((READY, (job, i, result, inqW_fd)))
File "/home/developer/.pyenv/versions/python3.6/lib/python3.6/site-packages/billiard/queues.py", line 366, in put
self.send_payload(ForkingPickler.dumps(obj))
File "/home/developer/.pyenv/versions/python3.6/lib/python3.6/site-packages/billiard/reduction.py", line 56, in dumps
cls(buf, protocol).dump(obj)
billiard.pool.MaybeEncodingError: Error sending result: '"(1, <ExceptionInfo: RetryError('<Future at 0x7fdf2212b710 state=finished raised ValueError>',)>, None)"'. Reason: ''PicklingError("Can\'t pickle <class \'tenacity.RetryError\'>: it\'s not the same object as tenacity.RetryError",)''.