Issue 1:
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

Issue #6158 is about REVOKED states not always being reflected, but I believe this issue is more specific (e.g. the state should not be RETRY).

Possible Duplicates

None

Environment & Settings

Celery version: 5.1.0 (sun-harmonics)

celery report Output:

$ celery -A celery_revoke_retry report

software -> celery:5.1.0 (sun-harmonics) kombu:5.1.0 py:3.7.9
billiard:3.6.4.0 redis:3.5.0
platform -> system:Linux arch:64bit, ELF
kernel version:3.10.0-1160.11.1.el7.x86_64 imp:CPython
loader -> celery.loaders.app.AppLoader
settings -> transport:redis results:redis://localhost:6379/0

broker_url: 'redis://localhost:6379/0'
result_backend: 'redis://localhost:6379/0'
deprecated_settings: None
worker_concurrency: 1

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:

Other Dependencies

N/A

Minimally Reproducible Test Case

import threading
import time
from celery import Celery

app = Celery('celery_revoke_retry', broker='redis://localhost:6379/0', backend='redis://localhost:6379/0')
app.conf.update(worker_concurrency=1)

@app.task
def sleep(sleep_time):
time.sleep(sleep_time)

def main():
argv = ['--app=celery_revoke_retry', 'worker', '--loglevel=DEBUG']
threading.Thread(target=app.worker_main, args=(argv,)).start()
time.sleep(5)
print('Celery should be up now')

r = sleep.s(sleep_time=60).apply_async()
# Note: waiting for the task to start before revoking it will still cause result.state == RETRY
r.revoke(terminate=True)

for _ in range(5):
print(f"State is: {r.state}")
time.sleep(1)

if __name__ == '__main__':
main()

Expected Behavior

After revoking the task, the expectation is that the state will not be RETRY. The state should be REVOKED, but my understanding is that there are other known issues that cause an un-received task to not have state=REVOKED after it is revoked.

Note that even if the code sample above waiting for the task to be started before executing the revoke, the state will still become RETRY.

This appears to be a Celery 5.x regression. The previous 4.x version I was on did not exhibit this behaviour.

Actual Behavior

The code above will print the following:

State is: PENDING
Terminating 289825dd-4c07-4018-907a-9f9763e941fe (Signals.SIGTERM)
State is: RETRY
State is: RETRY
State is: RETRY
State is: RETRY

Note that the state should be REVOKED, not RETRY. I believe the previous behaviour was that a task that was never received would stay PENDING if it is revoked.

Issue 2:
My configuration is as follows (running as administrator)

software -> celery:4.0.0 (latentcall) kombu:4.0.0 py:3.5.2
billiard:3.5.0.2 py-amqp:2.1.1
platform -> system:Windows arch:32bit, WindowsPE imp:CPython
loader -> celery.loaders.app.AppLoader
settings -> transport:amqp results:disabled

broker_url: 'amqp://guest:********@localhost:5672//'

Steps to reproduce (tasks.py)

from celery import Celery

app = Celery('tasks', broker='amqp://guest:guest@localhost:5672//')

@app.task(ignore_result=True, serializer='json')
def print_hello():
print('hello there')

@app.task(serializer='json')
def gen_prime(x):
multiples = []
results = []
for i in xrange(2, x+1):
if i not in multiples:
results.append(i)
for j in xrange(i*i, x+1, i):
multiples.append(j)
return results

celery worker -A tasks

Expected behavior

Worker running successfully

Actual behavior

-------------- celery@CMENGU-PC v4.0.0 (latentcall)
---- **** -----
--- * *** * -- Windows-7-6.1.7601-SP1 2016-11-07 23:25:16
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app: tasks:0x34f0790
- ** ---------- .> transport: amqp://guest:**@localhost:5672//
- ** ---------- .> results: disabled://
- *** --- * --- .> concurrency: 8 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
-------------- [queues]
.> celery exchange=celery(direct) key=celery

[2016-11-07 23:25:16,511: CRITICAL/MainProcess] Unrecoverable error: AttributeError("Can't pickle loca
l object 'Pool.__init__.<locals>.Process'",)
Traceback (most recent call last):
File "c:\users\cmengu\appdata\local\programs\python\python35-32\lib\site-packages\celery\worker\work
er.py", line 203, in start
self.blueprint.start(self)
File "c:\users\cmengu\appdata\local\programs\python\python35-32\lib\site-packages\celery\bootsteps.p
y", line 119, in start
step.start(parent)
File "c:\users\cmengu\appdata\local\programs\python\python35-32\lib\site-packages\celery\bootsteps.p
y", line 370, in start
return self.obj.start()
File "c:\users\cmengu\appdata\local\programs\python\python35-32\lib\site-packages\celery\concurrency
\base.py", line 131, in start
self.on_start()
File "c:\users\cmengu\appdata\local\programs\python\python35-32\lib\site-packages\celery\concurrency
\prefork.py", line 112, in on_start
**self.options)
File "c:\users\cmengu\appdata\local\programs\python\python35-32\lib\site-packages\billiard\pool.py",
line 1008, in __init__
self._create_worker_process(i)
File "c:\users\cmengu\appdata\local\programs\python\python35-32\lib\site-packages\billiard\pool.py",
line 1117, in _create_worker_process
w.start()
File "c:\users\cmengu\appdata\local\programs\python\python35-32\lib\site-packages\billiard\process.p
y", line 122, in start
self._popen = self._Popen(self)
File "c:\users\cmengu\appdata\local\programs\python\python35-32\lib\site-packages\billiard\context.p
y", line 383, in _Popen
return Popen(process_obj)
File "c:\users\cmengu\appdata\local\programs\python\python35-32\lib\site-packages\billiard\popen_spa
wn_win32.py", line 79, in __init__
reduction.dump(process_obj, to_child)
File "c:\users\cmengu\appdata\local\programs\python\python35-32\lib\site-packages\billiard\reduction
.py", line 99, in dump
ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object 'Pool.__init__.<locals>.Process'

C:\Users\CMENGU\Desktop\celery-app\messaging>Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\cmengu\appdata\local\programs\python\python35-32\lib\site-packages\billiard\spawn.py"
, line 159, in spawn_main
new_handle = steal_handle(parent_pid, pipe_handle)
File "c:\users\cmengu\appdata\local\programs\python\python35-32\lib\site-packages\billiard\reduction
.py", line 126, in steal_handle
_winapi.DUPLICATE_SAME_ACCESS | _winapi.DUPLICATE_CLOSE_SOURCE)
PermissionError: [WinError 5] Access is denied

It says a permission error but I am running on admin privileges. Not really sure whats going on.