Issue 1:
Checklist

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

I have included all related issues and possible duplicate issues in this issue.

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

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

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 workers pool.

I have tried reproducing the issue with retries, ETA/Countdown & rate limits disabled.

Related Issues and Possible Duplicates

#4707

#4709

#4721

Environment & Settings

Celery version: 4.3.0rc1

celery report Output:

$ celery -A bug report

software -> celery:4.3.0rc1 (rhubarb) kombu:4.4.0 py:3.7.2
billiard:3.6.0.0 redis:3.2.1
platform -> system:Linux arch:64bit
kernel version:4.9.125-linuxkit imp:CPython
loader -> celery.loaders.app.AppLoader
settings -> transport:redis results:redis://redis:6379/0

broker_url: 'redis://redis:6379/0'
result_backend: 'redis://redis:6379/0'

Steps to Reproduce

Required Dependencies

Minimal Python Version: Python 3.5

Minimal Broker Version: Redis 3.0

Minimal Result Backend Version: Redis 3.0

Minimal OS and/or Kernel Version: Linux (Docker for Mac)

Minimal Broker Client Version: redis-py 3.2.1

Minimal Result Backend Client Version: redis-py 3.2.1

Python Packages

pip freeze Output:

amqp==2.4.2 # via kombu
billiard==3.6.0.0 # via celery
celery[redis]==4.3.0rc1
kombu==4.4.0
pytz==2018.9 # via celery
redis==3.2.1 # via celery
vine==1.3.0 # via amqp

Minimally Reproducible Test Case

# bug/celery.py
from celery import Celery
from redis import StrictRedis

REDIS_URL = 'redis://redis:6379/0'

app = Celery(
'bug',
broker=REDIS_URL,
backend=REDIS_URL,
)

redis = StrictRedis.from_url(REDIS_URL)

@app.task(ignore_result=True)
def ignore_me_A(key, value):
redis.set(key, value)

@app.task
def ignore_me_B(key, value):
redis.set(key, value)

# bug/main.py
from time import sleep, time
from .celery import ignore_me_A, ignore_me_B, redis

KEY_PATTERN = 'celery-task-meta-*'

def value_equals(key, expected):
raw = redis.get(key)
if raw:
return raw.decode('utf-8') == expected
return False

def test_task_result(task):
assert len(list(redis.scan_iter(KEY_PATTERN))) == 0

key = f'results/{task.name}'
value = str(time())
task.apply_async((key, value), ignore_result=True)

while not value_equals(key, value):
print(f'waiting for result of {key}')
sleep(1.0)

redis.delete(key)
assert len(list(redis.scan_iter(KEY_PATTERN))) == 0
print('result of `ignore_me_A` is not persisted')

def main():
for key in redis.scan_iter(KEY_PATTERN):
redis.delete(key)

test_task_result(ignore_me_A)
test_task_result(ignore_me_B)

if __name__ == "__main__":
main()

Expected Behavior

Start Celery worker (celery -A bug worker) and execute python3 -m bug.main - there should be no "celery-task-meta-*" keys in Redis, and the output should be:

waiting for result of results/bug.celery.ignore_me_A
...
result of `ignore_me_A` is not persisted

waiting for result of results/bug.celery.ignore_me_B
...
result of `ignore_me_B` is not persisted

Actual Behavior

python3 -m bug.main exits with error:

waiting for result of results/bug.celery.ignore_me_A
...
result of `ignore_me_A` is not persisted

waiting for result of results/bug.celery.ignore_me_B
...
Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/src/bug/main.py", line 39, in <module>
main()
File "/src/bug/main.py", line 35, in main
test_task_result(ignore_me_B)
File "/src/bug/main.py", line 26, in test_task_result
assert len(list(redis.scan_iter(KEY_PATTERN))) == 0
AssertionError

And redis-cli keys * shows:

1) "_kombu.binding.celery"
2) "_kombu.binding.celeryev"
3) "celery-task-meta-8406a282-ea03-439c-bc49-91a56e201860"
4) "_kombu.binding.celery.pidbox"

Issue 2:
I know there are a few other posts similar to this already, and I have copied their solutions.

Example = app.register_task(Example())
Example.apply_async()

But this format does not register tasks. I think there must be a simple problem with my app or celery settings. Class-based tasks are still supposed to work, right? When I run tasks.py in isolation and print tasks, I can see the class-based tasks as registered. By the time they get to the workers, they are no longer registered, but my decorator-based tasks are.

Edit: Further work. When I run

celery -A caliper.celery.celery_app:app inspect registered

I can actually see the QueuedOneTimeSurvey task in there, BUT the workers are - empty -. When I add a task to the queue, then all of the decorator-base tasks get added to the workers, but the lone class-based task doesn't get added.

Checklist

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

This has already been asked to the discussion group first.

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

#4112

#3874

#3744

Possible Duplicates

None

Environment & Settings

Celery version: 4.4.0

celery report Output:

software -> celery:4.4.0 (cliffs) kombu:4.6.8 py:3.7.6
billiard:3.6.3.0 py-amqp:2.5.2
platform -> system:Linux arch:64bit, ELF
kernel version:4.4.0-1098-aws imp:CPython
loader -> celery.loaders.app.AppLoader
settings -> transport:amqp results:disabled

CELERYD_LOG_LEVEL: 'INFO'
CELERY_ACCEPT_CONTENT: ['pickle']
CELERY_BROKER_URL: 'amqp://staging:********@********'
CELERY_IMPORTS: ['caliper.celery.tasks',
'caliper.celery.tasks_lambda']
CELERY_RESULT_SERIALIZER: 'pickle'
CELERY_SEND_TASK_ERROR_EMAILS: True
CELERY_TASK_DEFAULT_EXCHANGE: 'default'
CELERY_TASK_DEFAULT_EXCHANGE_TYPE: 'direct'
CELERY_TASK_DEFAULT_QUEUE: 'caliper.default'
CELERY_TASK_IGNORE_RESULT: True
CELERY_TASK_QUEUES: {
'caliper.OneTimeSurvey': {'binding_key': '********'},
'caliper.default': {'binding_key': '********'}}
CELERY_TASK_ROUTES:
('caliper.celery.routers.CaliperRouter',)
CELERY_TASK_SERIALIZER: 'pickle'
CELERY_WORKER_PREFETCH_MULTIPLIER: 4
binding: {
'binding_key': '********'}
existing: {
}
os: <module 'os' from '/usr/lib/python3.7/os.py'>
q: 'caliper.OneTimeSurvey'
settings: <module 'siphon.settings' from '/deploy/siphon/siphon/settings.py'>
settings_messagebroker: <module 'siphon.settings_messagebroker' from '/deploy/siphon/siphon/settings_messagebroker.py'>
task_protocol: 1

Steps to Reproduce

Required Dependencies

Minimal Python Version: 3.7

Minimal Celery Version: 4.4.0

Minimal Kombu Version: 4.6.8

Minimal Broker Version: N/A or Unknown

Minimal Result Backend Version: N/A or Unknown

Minimal OS and/or Kernel Version: Ubuntu 16

Minimal Broker Client Version: N/A or Unknown

Minimal Result Backend Client Version: N/A or Unknown

Python Packages

pip freeze Output:

amqp==2.5.2
anyjson==0.3.3
asgiref==3.2.3
backcall==0.1.0
bcrypt==3.1.7
beautifulsoup4==4.5.1
billiard==3.6.3.0
boto==2.38.0
boto3==1.4.0
botocore==1.4.93
celery==4.4.0
certifi==2019.11.28
cffi==1.14.0
chardet==3.0.4
concurrencytest==0.1.2
cryptography==2.8
decorator==4.4.1
Django==3.0
django-localflavor==2.2
django-ses==0.8.13
django-timedeltafield==0.7.10
djorm-pgarray==1.2
docutils==0.16
dogslow==1.2
ExifRead==2.1.2
extras==1.0.0
facebook-sdk==3.1.0
fixtures==3.0.0
flickrapi==2.4.0
future==0.18.2
geographiclib==1.50
geojson==2.5.0
geopy==1.20.0
graypy==2.1.0
html2text==2019.9.26
httplib2==0.14.0
idna==2.8
importlib-metadata==1.5.0
ipython==7.10.2
ipython-genutils==0.2.0
iso8601==0.1.12
jedi==0.16.0
jmespath==0.9.4
kafka==1.3.5
kombu==4.6.8
linecache2==1.0.0
lxml==4.5.0
mock==3.0.5
nose==1.3.7
numpy==1.17.4
oauth==1.0.1
oauth2==1.9.0.post1
oauthlib==3.1.0
overpy==0.4
pandas==0.25.3
paramiko==2.7.1
parso==0.6.1
pbr==5.4.4
pexpect==4.8.0
pickleshare==0.7.5
Pillow==6.2.1
prompt-toolkit==3.0.3
psycopg2==2.7.5
ptyprocess==0.6.0
pycparser==2.19
Pygments==2.5.2
pykml==0.2.0
pylibmc==1.6.1
PyNaCl==1.3.0
python-dateutil==2.8.1
python-mimeparse==1.6.0
python-stdnum==1.13
python-subunit==1.3.0
pytz==2019.3
raven==6.10.0
requests==2.22.0
requests-oauthlib==1.3.0
requests-toolbelt==0.9.1
s3transfer==0.1.13
scipy==1.4.0
selenium==3.141.0
simplekml==1.3.1
six==1.14.0
SQLAlchemy==1.3.12
sqlalchemy-redshift==0.7.5
sqlparse==0.3.0
testtools==2.3.0
traceback2==1.4.0
traitlets==4.3.3
unittest2==1.1.0
urllib3==1.25.8
utm==0.5.0
vine==1.3.0
virtualenv==16.7.9
wcwidth==0.1.8
xlrd==1.2.0
xlwt==1.3.0
zipp==3.0.0

Other Dependencies

N/A

Minimally Reproducible Test Case

CELERY_TASK_IGNORE_RESULT = True

CELERY_IMPORTS = ['cal.celery.tasks', 'cal.tasks_lambda']

CELERY_TASK_ROUTES = ('cal.celery.routers.Router', )

CELERY_TASK_QUEUES = {
'caliper.OneTimeSurvey': ****,
}

for q in CELERY_TASK_QUEUES:
existing = CELERY_TASK_QUEUES[q]
binding = {'binding_key': q}
CELERY_TASK_QUEUES[q] = dict(list(existing.items()) + list(binding.items()))

CELERY_TASK_DEFAULT_QUEUE = 'cal.default'
CELERY_TASK_DEFAULT_EXCHANGE = 'default'
CELERY_TASK_DEFAULT_EXCHANGE_TYPE = 'direct'

CELERY_SEND_TASK_ERROR_EMAILS = True
CELERYD_LOG_LEVEL = "INFO"

CELERY_ACCEPT_CONTENT = ['pickle']
CELERY_TASK_SERIALIZER = 'pickle'
CELERY_RESULT_SERIALIZER = 'pickle'

CELERY_WORKER_PREFETCH_MULTIPLIER = 4

import django
django.setup()

from siphon import settings_celery
import celery
from celery import Celery

app = Celery(accept_content=['pickle'])
app.conf.task_protocol = 1
app.config_from_object(settings_celery, namespace='CELERY')

class QueuedOneTimeSurvey(celery.Task):
name='QueuedOneTimeSurvey'

def run(self):
@transaction.atomic
def run_inner():
print("hello")
return run_inner()
QueuedOneTimeSurvey = app.register_task(QueuedOneTimeSurvey())

QueuedOneTimeSurveyTask.apply_async()

Expected Behavior

I expect the task to register and execute.

Actual Behavior

[2020-03-06 16:23:29,425: ERROR/MainProcess] Received unregistered task of type 'QueuedOneTimeSurvey'.
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'\x80\x02}q\x00(X\x04\x00\x00\x00taskq\x01X\x13\x00\x00\x00QueuedOneTimeSurveyq\x02X\x02\x00\x00\x00idq\x03X$\x00\x00\x0040f69c1a-c201-4498-9e36-43abe605a2f2q\x04X\x04\x00\x00\x00argsq\x05)X\x06\x00\x00\x00kwargsq\x06}q\x07X\x05\x00\x00\x00groupq\x08NX\x07\x00\x00\x00retriesq\tK\x00X\x03\x00\x00\x00etaq\nNX\x07\x00\x00\x00expiresq\x0bNX\x03\x00\x00\x00utcq\x0c\x88X\t\x00\x00\x00callbacksq\rNX\x08\x00\x00\x00errbacksq\x0eNX\t\x00\x00\x00timelimitq\x0fNN\x86q\x10X\x07\x00\x00\x00tasksetq\x11NX\x05\x00\x00\x00chordq\x12Nu.' (273b)
Traceback (most recent call last):
File "/deploy/pythonenvs/env/lib/python3.7/site-packages/celery/worker/consumer/consumer.py", line 559, in on_task_received
strategy = strategies[type_]
KeyError: 'QueuedOneTimeSurvey'