<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 class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> 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"> 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"> I have verified that the issue exists against the <code class="notranslate">master</code> branch of Celery. (<b>Note on this</b> -- I am using the latest version of Celery from Pip, though I am not building/installing from source)</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"> 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"> 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>: 5.1.2</p>

<details>
<summary><b><code class="notranslate">celery report</code> Output:</b></summary>
<p dir="auto">
</p><div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="software -&gt; 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 -&gt; system:Linux arch:64bit
            kernel version:5.10.47-linuxkit imp:CPython
loader   -&gt; celery.loaders.app.AppLoader
settings -&gt; transport:amqp results:rpc://redis:6379/

broker_url: 'amqp://changeme:********@rabbitmq:5672//'
result_backend: 'rpc://redis:6379/'
deprecated_settings: None"><pre class="notranslate"><code class="notranslate">software -&gt; 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 -&gt; system:Linux arch:64bit
            kernel version:5.10.47-linuxkit imp:CPython
loader   -&gt; celery.loaders.app.AppLoader
settings -&gt; transport:amqp results:rpc://redis:6379/

broker_url: 'amqp://changeme:********@rabbitmq:5672//'
result_backend: 'rpc://redis:6379/'
deprecated_settings: None
</code></pre></div>
<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.9</li>
<li><strong>Minimal Celery Version</strong>: 5.1.2</li>
<li><strong>Minimal Kombu Version</strong>: 5.1.0</li>
<li><strong>Minimal Broker Version</strong>: RabbitMQ 3.9.5</li>
<li><strong>Minimal Result Backend Version</strong>: Redis 6.2.5</li>
<li><strong>Minimal OS and/or Kernel Version</strong>: Debian Bullseye (official <a href="https://github.com/docker-library/python/blob/f154e5d1c8f5b582aa2fd782df880b9cc96bb431/3.9/bullseye/slim/Dockerfile">python3.9-slim</a> Docker image)</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="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"><pre class="notranslate"><code class="notranslate">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
</code></pre></div>
<p dir="auto"></p>
</details>
<h3 dir="auto">Other Dependencies</h3>

<details>
<summary><b>My Full Dockerfile:</b></summary>
<p dir="auto">
</p><div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="FROM python:3.9-slim

# Set bash to default shell
RUN rm /bin/sh &amp;&amp; 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 &amp;&amp; \
		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 &amp;&amp; \
		apt dist-upgrade -y

ENV VIRTUAL_ENV=/venv
RUN python3.9 -m venv $VIRTUAL_ENV
ENV PATH=&quot;$VIRTUAL_ENV/bin:$PATH&quot;

# 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"><pre class="notranslate"><code class="notranslate">FROM python:3.9-slim

# Set bash to default shell
RUN rm /bin/sh &amp;&amp; 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 &amp;&amp; \
		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 &amp;&amp; \
		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
</code></pre></div>
<p dir="auto"></p>
</details>
<h2 dir="auto">Minimally Reproducible Test Case</h2>

<details>
<summary>Simple addition task with celery's "group" object, "send_task()", and "apply_async()"</summary>
<p dir="auto">
</p><div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="#!/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 &quot;add&quot; 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()"><pre class="notranslate"><span class="pl-c">#!/usr/bin/env python</span>

<span class="pl-k">from</span> <span class="pl-s1">celery</span> <span class="pl-k">import</span> <span class="pl-v">Celery</span>, <span class="pl-s1">group</span>
<span class="pl-k">import</span> <span class="pl-s1">random</span>
<span class="pl-k">import</span> <span class="pl-s1">os</span>

<span class="pl-s1">app</span> <span class="pl-c1">=</span> <span class="pl-v">Celery</span>(
	<span class="pl-s">'consumer'</span>,
	<span class="pl-s1">broker</span><span class="pl-c1">=</span><span class="pl-s">f'''amqp://<span class="pl-s1"><span class="pl-kos">{</span><span class="pl-s1">os</span>.<span class="pl-en">getenv</span>(<span class="pl-s">'RABBITMQ_DEFAULT_USER'</span>)<span class="pl-kos">}</span></span>:<span class="pl-s1"><span class="pl-kos">{</span><span class="pl-s1">os</span>.<span class="pl-en">getenv</span>(<span class="pl-s">'RABBITMQ_DEFAULT_PASS'</span>)<span class="pl-kos">}</span></span>@<span class="pl-s1"><span class="pl-kos">{</span><span class="pl-s1">os</span>.<span class="pl-en">getenv</span>(<span class="pl-s">'RABBITMQ_HOST'</span>)<span class="pl-kos">}</span></span>:<span class="pl-s1"><span class="pl-kos">{</span><span class="pl-s1">os</span>.<span class="pl-en">getenv</span>(<span class="pl-s">'RABBITMQ_PORT'</span>)<span class="pl-kos">}</span></span>'''</span>,
	<span class="pl-s1">backend</span><span class="pl-c1">=</span><span class="pl-s">'rpc://redis:6379'</span>
)

<span class="pl-en">@<span class="pl-s1">app</span>.<span class="pl-en">task</span>(<span class="pl-s1">name</span><span class="pl-c1">=</span><span class="pl-s">'add'</span>)</span>
<span class="pl-k">def</span> <span class="pl-en">add</span>(<span class="pl-s1">n1</span>, <span class="pl-s1">n2</span>):
	<span class="pl-k">return</span> <span class="pl-s1">n1</span> <span class="pl-c1">+</span> <span class="pl-s1">n2</span>

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

<span class="pl-en">main</span>()</pre></div>
<p dir="auto"></p>
</details>
<h1 dir="auto">Expected Behavior</h1>
<p dir="auto">The tasks are completed asynchronously and all resulting sums are saved as <code class="notranslate">results</code> (as such the program waits until all tasks are done before exiting).</p>
<h1 dir="auto">Actual Behavior</h1>

<p dir="auto">A TypeError is raised in <code class="notranslate">celery/backends/asynchronous.py</code> 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 <code class="notranslate">timeout</code> is set by default in <code class="notranslate">drain_events_until</code> to <code class="notranslate">None</code>. I'm wondering if this value is being accidentally set elsewhere in celery's code. I have also tried explicitly setting <code class="notranslate">timeout=None</code> when calling <code class="notranslate">apply_async</code> and the same error occurs.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
  File &quot;/app/main.py&quot;, line 21, in main
    jobs = pool.apply_async() # .apply_async() raises an error in the drain_events_until method in celery.backends.asynchronous
  File &quot;/venv/lib/python3.9/site-packages/celery/canvas.py&quot;, line 1090, in apply_async
    results = list(self._apply_tasks(tasks, producer, app, p,
  File &quot;/venv/lib/python3.9/site-packages/celery/canvas.py&quot;, line 1182, in _apply_tasks
    lookahead(tasks)
  File &quot;/venv/lib/python3.9/site-packages/celery/utils/functional.py&quot;, line 174, in lookahead
    next(b, None)
  File &quot;/venv/lib/python3.9/site-packages/celery/canvas.py&quot;, line 1157, in _prepared
    task = from_dict(task, app=app)
  File &quot;/venv/lib/python3.9/site-packages/celery/canvas.py&quot;, line 134, in from_dict
    typ = d.get('subtask_type')
  File &quot;/venv/lib/python3.9/site-packages/celery/result.py&quot;, line 223, in get
    return self.backend.wait_for_pending(
  File &quot;/venv/lib/python3.9/site-packages/celery/backends/asynchronous.py&quot;, line 199, in wait_for_pending
    for _ in self._wait_for_pending(result, **kwargs):
  File &quot;/venv/lib/python3.9/site-packages/celery/backends/asynchronous.py&quot;, line 265, in _wait_for_pending
    for _ in self.drain_events_until(
  File &quot;/venv/lib/python3.9/site-packages/celery/backends/asynchronous.py&quot;, line 51, in drain_events_until
    if timeout and time.monotonic() - time_start &gt;= timeout:
TypeError: '&gt;=' not supported between instances of 'float' and 'str'"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  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 &gt;= timeout:
TypeError: '&gt;=' not supported between instances of 'float' and 'str'
</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 checked the <a href="https://github.com/celery/celery/issues?q=is%3Aissue+label%3A%22Issue+Type%3A+Enhancement%22+-label%3A%22Category%3A+Documentation%22">issues list</a><br>
for similar or identical enhancement to an existing feature.</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%22Issue+Type%3A+Enhancement%22+-label%3A%22Category%3A+Documentation%22">pull requests list</a><br>
for existing proposed enhancements.</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 if the same enhancement was already implemented in the<br>
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 in this issue<br>
(If there are none, check this box anyway).</li>
</ul>
<h4 dir="auto">Related Issues</h4>
<p dir="auto"><a href="https://stackoverflow.com/questions/16493364/stopping-celery-task-gracefully" rel="nofollow">https://stackoverflow.com/questions/16493364/stopping-celery-task-gracefully</a></p>
<h4 dir="auto">Possible Duplicates</h4>
<ul dir="auto">
<li>None</li>
</ul>
<h1 dir="auto">Brief Summary</h1>
<p dir="auto">Im using celery to execute python subprocess (Bash script ) in the background , My bash script will keep running until it receive <strong>CTRL+C</strong> to stop and do some <strong>cleaning in the OS</strong> ,  i tried to use</p>
<p dir="auto"><code class="notranslate">app.control.revoke('d9078da5-9915-40a0-bfa1-392c7bde42ed',terminate=True, signal='SIGINT')</code></p>
<p dir="auto">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 ,</p>
<p dir="auto">Example :<br>
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 .</p>
<p dir="auto"><strong>How i can send CTRL+C to the running process ?</strong></p>
<p dir="auto">I tried<br>
<a href="http://docs.celeryproject.org/en/latest/userguide/workers.html#revoke-revoking-tasks" rel="nofollow">http://docs.celeryproject.org/en/latest/userguide/workers.html#revoke-revoking-tasks</a><br>
<a href="https://docs.python.org/dev/library/signal.html#module-signal" rel="nofollow">https://docs.python.org/dev/library/signal.html#module-signal</a><br>
but nothing works .</p>
<p dir="auto">FYI , im  using latest version of celery and python 3.7 with debain</p>