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. (Note on this -- I am using the latest version of Celery from Pip, though I am not building/installing from source)

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

None

Possible Duplicates

None

Environment & Settings

Celery version: 5.1.2

celery report Output:

software -> celery:5.1.2 (sun-harmonics) kombu:5.1.0 py:3.9.6
billiard:3.6.4.0 py-amqp:5.0.6
platform -> system:Linux arch:64bit
kernel version:5.10.47-linuxkit imp:CPython
loader -> celery.loaders.app.AppLoader
settings -> transport:amqp results:rpc://redis:6379/

broker_url: 'amqp://changeme:********@rabbitmq:5672//'
result_backend: 'rpc://redis:6379/'
deprecated_settings: None

Steps to Reproduce

Required Dependencies

Minimal Python Version: 3.9

Minimal Celery Version: 5.1.2

Minimal Kombu Version: 5.1.0

Minimal Broker Version: RabbitMQ 3.9.5

Minimal Result Backend Version: Redis 6.2.5

Minimal OS and/or Kernel Version: Debian Bullseye (official python3.9-slim Docker image)

Python Packages

pip freeze Output:

amqp==5.0.6
appdirs==1.4.4
beautifulsoup4==4.9.3
billiard==3.6.4.0
bs4==0.0.1
cachetools==4.2.2
celery==5.1.2
certifi==2021.5.30
charset-normalizer==2.0.4
click==7.1.2
click-didyoumean==0.0.3
click-plugins==1.1.1
click-repl==0.2.0
cssselect==1.1.0
DateTime==4.3
fake-useragent==0.1.11
future==0.18.2
google-api-core==2.0.0
google-api-python-client==2.17.0
google-auth==2.0.1
google-auth-httplib2==0.1.0
google-auth-oauthlib==0.4.5
googleapis-common-protos==1.53.0
httplib2==0.19.1
idna==3.2
importlib-metadata==4.6.4
kombu==5.1.0
lxml==4.6.3
oauthlib==3.1.1
parse==1.19.0
prompt-toolkit==3.0.20
protobuf==3.17.3
pyArango==1.3.5
pyasn1==0.4.8
pyasn1-modules==0.2.8
pyee==8.2.2
pyparsing==2.4.7
pyppeteer==0.2.6
pyquery==1.4.3
pytz==2021.1
requests==2.26.0
requests-html==0.10.0
requests-oauthlib==1.3.0
rsa==4.7.2
six==1.15.
soupsieve==2.2.1
tqdm==4.62.1
uritemplate==3.0.1
urllib3==1.26.6
vine==5.0.0
w3lib==1.22.0
wcwidth==0.2.5
websockets==9.1
zipp==3.5.0
zope.interface==5.4.0

Other Dependencies

My Full Dockerfile:

FROM python:3.9-slim

# Set bash to default shell
RUN rm /bin/sh && ln -s /bin/bash /bin/sh

# Do not prompt apt for user input when installing packages
ENV DEBIAN_FRONTEND=noninteractive

# Install dependencies
RUN apt update && \
apt install -y \
build-essential supervisor software-properties-common \
gconf-service libasound2 libatk1.0-0 libc6 libcairo2 \
libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 \
libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 \
libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 \
libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 \
libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 \
libxrender1 libxss1 libxtst6 ca-certificates \
fonts-liberation libnss3 lsb-release xdg-utils wget && \
apt dist-upgrade -y

ENV VIRTUAL_ENV=/venv
RUN python3.9 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

# Upgrade pip
RUN python -m pip install --upgrade pip

# Install python packages
RUN pip install --no-dependencies \
amqp==5.0.6 \
appdirs==1.4.4 \
beautifulsoup4==4.9.3 \
billiard==3.6.4.0 \
bs4==0.0.1 \
cachetools==4.2.2 \
celery==5.1.2 \
certifi==2021.5.30 \
charset-normalizer==2.0.4 \
click==7.1.2 \
click-didyoumean==0.0.3 \
click-plugins==1.1.1 \
click-repl==0.2.0 \
cssselect==1.1.0 \
DateTime==4.3 \
fake-useragent==0.1.11 \
future==0.18.2 \
google-api-core==2.0.0 \
google-api-python-client==2.17.0 \
google-auth==2.0.1 \
google-auth-httplib2==0.1.0 \
google-auth-oauthlib==0.4.5 \
googleapis-common-protos==1.53.0 \
httplib2==0.19.1 \
idna==3.2 \
importlib-metadata==4.6.4 \
kombu==5.1.0 \
lxml==4.6.3 \
oauthlib==3.1.1 \
parse==1.19.0 \
prompt-toolkit==3.0.20 \
protobuf==3.17.3 \
pyArango==1.3.5 \
pyasn1==0.4.8 \
pyasn1-modules==0.2.8 \
pyee==8.2.2 \
pyparsing==2.4.7 \
pyppeteer==0.2.6 \
pyquery==1.4.3 \
pytz==2021.1 \
requests==2.26.0 \
requests-html==0.10.0 \
requests-oauthlib==1.3.0 \
rsa==4.7.2 \
six==1.15.0 \
soupsieve==2.2.1 \
tqdm==4.62.1 \
uritemplate==3.0.1 \
urllib3==1.26.6 \
vine==5.0.0 \
w3lib==1.22.0 \
wcwidth==0.2.5 \
websockets==9.1 \
zipp==3.5.0 \
zope.interface==5.4.0

# Run pyppeteer download/install chromium script
RUN pyppeteer-install

# Add supervisord app config files
ADD conf/supervise-* /etc/supervisor/conf.d/

# Add app files
RUN mkdir /app
ADD producer.py /app/producer.py
ADD consumer.py /app/consumer.py
ADD db /app/db

# Let 'er rip
CMD /usr/bin/supervisord -n

Minimally Reproducible Test Case

Simple addition task with celery's "group" object, "send_task()", and "apply_async()"

#!/usr/bin/env python

from celery import Celery, group
import random
import os

app = Celery(
'consumer',
broker=f'''amqp://{os.getenv('RABBITMQ_DEFAULT_USER')}:{os.getenv('RABBITMQ_DEFAULT_PASS')}@{os.getenv('RABBITMQ_HOST')}:{os.getenv('RABBITMQ_PORT')}''',
backend='rpc://redis:6379'
)

@app.task(name='add')
def add(n1, n2):
return n1 + n2

def main():
# Build a group of 5 "add" tasks with two arguments, each of which are a random integer between 0 and 10
pool = group([app.send_task('add', (random.randint(0,10), random.randint(0,10))) for i in range(0,5)])
# Complete tasks asynchronously with .apply_async()
jobs = pool.apply_async() # .apply_async() raises an error in the drain_events_until method in celery.backends.asynchronous
# Get results of tasks
results = jobs.join()

main()

Expected Behavior

The tasks are completed asynchronously and all resulting sums are saved as results (as such the program waits until all tasks are done before exiting).

Actual Behavior

A TypeError is raised in celery/backends/asynchronous.py because of an attempt to perform a mathematical calculation between unsupported types. I've done my best to trace this problem and have seen the argument timeout is set by default in drain_events_until to None. I'm wondering if this value is being accidentally set elsewhere in celery's code. I have also tried explicitly setting timeout=None when calling apply_async and the same error occurs.

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/app/main.py", line 21, in main
jobs = pool.apply_async() # .apply_async() raises an error in the drain_events_until method in celery.backends.asynchronous
File "/venv/lib/python3.9/site-packages/celery/canvas.py", line 1090, in apply_async
results = list(self._apply_tasks(tasks, producer, app, p,
File "/venv/lib/python3.9/site-packages/celery/canvas.py", line 1182, in _apply_tasks
lookahead(tasks)
File "/venv/lib/python3.9/site-packages/celery/utils/functional.py", line 174, in lookahead
next(b, None)
File "/venv/lib/python3.9/site-packages/celery/canvas.py", line 1157, in _prepared
task = from_dict(task, app=app)
File "/venv/lib/python3.9/site-packages/celery/canvas.py", line 134, in from_dict
typ = d.get('subtask_type')
File "/venv/lib/python3.9/site-packages/celery/result.py", line 223, in get
return self.backend.wait_for_pending(
File "/venv/lib/python3.9/site-packages/celery/backends/asynchronous.py", line 199, in wait_for_pending
for _ in self._wait_for_pending(result, **kwargs):
File "/venv/lib/python3.9/site-packages/celery/backends/asynchronous.py", line 265, in _wait_for_pending
for _ in self.drain_events_until(
File "/venv/lib/python3.9/site-packages/celery/backends/asynchronous.py", line 51, in drain_events_until
if timeout and time.monotonic() - time_start >= timeout:
TypeError: '>=' not supported between instances of 'float' and 'str'

Issue 2:
Checklist

I have checked the issues list

for similar or identical enhancement to an existing feature.

I have checked the pull requests list

for existing proposed enhancements.

I have checked the commit log

to find out if the if the same enhancement was already implemented 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).

Related Issues

https://stackoverflow.com/questions/16493364/stopping-celery-task-gracefully

Possible Duplicates

None

Brief Summary

Im using celery to execute python subprocess (Bash script ) in the background , My bash script will keep running until it receive CTRL+C to stop and do some cleaning in the OS , i tried to use

app.control.revoke('d9078da5-9915-40a0-bfa1-392c7bde42ed',terminate=True, signal='SIGINT')

But the task keep running in the background , i read the docs and issues list and i could not get clear answer how i can send CTRL+C to the running worker telling him to stop the task using CTRL+C not terminating the task by killing the process because if i kill the process , my background process will break my OS ,

Example :

My background program (Bash script) doing some analytic and it will never stop until i click ctrl+c , when i click ctrl+c the bash script will restore all settings to default , in other hand if i kill the process the settings will remain changed .

How i can send CTRL+C to the running process ?

I tried

http://docs.celeryproject.org/en/latest/userguide/workers.html#revoke-revoking-tasks

https://docs.python.org/dev/library/signal.html#module-signal

but nothing works .

FYI , im using latest version of celery and python 3.7 with debain