Issue 1:
I'm receiving an AssertionError when running Celery. The issue is persistent and repeatable in that, if I run a job with ~700,000 subtasks, the issue occurs at some point well into the job. However, it does not occur if I run a job with only 180 subtasks.

[2014-06-10 10:27:51,355: ERROR/MainProcess] Unrecoverable error: AssertionError()
Traceback (most recent call last):
File "/Users/beccapetrin/Documents/Development/automated_reports/lib/python2.7/site-packages/celery/worker/__init__.py", line 206, in start
self.blueprint.start(self)
File "/Users/beccapetrin/Documents/Development/automated_reports/lib/python2.7/site-packages/celery/bootsteps.py", line 123, in start
step.start(parent)
File "/Users/beccapetrin/Documents/Development/automated_reports/lib/python2.7/site-packages/celery/bootsteps.py", line 373, in start
return self.obj.start()
File "/Users/beccapetrin/Documents/Development/automated_reports/lib/python2.7/site-packages/celery/worker/consumer.py", line 278, in start
blueprint.start(self)
File "/Users/beccapetrin/Documents/Development/automated_reports/lib/python2.7/site-packages/celery/bootsteps.py", line 123, in start
step.start(parent)
File "/Users/beccapetrin/Documents/Development/automated_reports/lib/python2.7/site-packages/celery/worker/consumer.py", line 821, in start
c.loop(*c.loop_args())
File "/Users/beccapetrin/Documents/Development/automated_reports/lib/python2.7/site-packages/celery/worker/loops.py", line 72, in asynloop
next(loop)
File "/Users/beccapetrin/Documents/Development/automated_reports/lib/python2.7/site-packages/kombu/async/hub.py", line 324, in create_loop
cb(*cbargs)
File "/Users/beccapetrin/Documents/Development/automated_reports/lib/python2.7/site-packages/celery/concurrency/asynpool.py", line 263, in on_result_readable
next(it)
File "/Users/beccapetrin/Documents/Development/automated_reports/lib/python2.7/site-packages/celery/concurrency/asynpool.py", line 200, in _recv_message
assert not isblocking(fd)
AssertionError

Here are my config details:

$ celery report

software -> celery:3.1.12 (Cipater) kombu:3.0.19 py:2.7.5
billiard:3.3.0.17 py-amqp:1.4.5
platform -> system:Darwin arch:64bit imp:CPython
loader -> celery.loaders.default.Loader
settings -> transport:amqp results:amqp://username:password@localhost:5672

CELERY_QUEUES:
(<unbound Queue automated_reports -> <unbound Exchange default(direct)> -> automated_reports>,)
CELERY_DEFAULT_ROUTING_KEY: '********'
CELERY_IMPORTS:
('automated_reports.queue.tasks', 'automated_reports.queue.subtasks')
CELERY_RESULT_PERSISTENT: True
CELERY_ROUTES: {
'automated_reports.queue.tasks.run_device_info_report': { 'queue': 'automated_reports'},
'uploader.queue.subtasks.multithread_device_listing': { 'queue': 'automated_reports'},
'uploader.queue.subtasks.multithread_individual_device': { 'queue': 'automated_reports'},
'uploader.queue.tasks.multithread_device_listing': { 'queue': 'automated_reports'},
'uploader.queue.tasks.multithread_individual_device': { 'queue': 'automated_reports'}}
CELERY_DEFAULT_QUEUE: 'automated_reports'
BROKER_URL: 'amqp://guest:********@localhost:5672//'
CELERY_RESULT_BACKEND: 'amqp://username:password@localhost:5672'

My worker startup command is:

~/Documents/Development/automated_reports/bin/celeryd --loglevel=DEBUG --autoreload -A automated_reports.queue.tasks -Q automated_reports -B --schedule=~/Documents/Development/automated_reports/log/celerybeat --autoscale=10,3 -Ofair

I run my application as a task, which then kicks off subtasks by using celery subtasks that are grouped together.

OS version is Mac OS X, version 10.9.3.

Issue was also posted on StackOverflow originally to post details and chat about before posting here: http://stackoverflow.com/questions/24152180/celery-assertionerror . . . I will add the outcome there too.

Issue 2:
Checklist

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).

software -> celery:4.0.2 (latentcall) kombu:4.0.2 py:3.5.2
billiard:3.5.0.2 py-amqp:2.1.4
platform -> system:Darwin arch:64bit imp:CPython
loader -> celery.loaders.app.AppLoader
settings -> transport:amqp results:redis://localhost/

result_backend: 'redis://localhost/'

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

Steps to reproduce:

Create code for a random task and a task_revoked handler in app.py:

import time

from celery import Celery
from celery.signals import task_revoked

app = Celery('app', backend='redis://localhost')

@app.task
def test():
# random task
counter = 0
while counter < 20:
print(str(counter))
time.sleep(1)
counter += 1

@task_revoked.connect
def on_task_revoked(*args, **kwargs):
print(str(kwargs))
print('task_revoked')

Start worker:

celery -A app worker --loglevel=info

Then start the task and revoke it:

>>> from celery.task.control import revoke
>>> from app import test
>>> id = test.delay().id
>>> revoke(id, terminate=True)

Expected behavior

I would expect on_task_revoked to be called once.

Actual behavior

Looking at the output of the worker, it seems that on_task_revoked is actually called twice:

...
[2017-02-01 17:08:53,361: WARNING/PoolWorker-1] 6
[2017-02-01 17:08:54,362: WARNING/PoolWorker-1] 7
[2017-02-01 17:08:55,363: WARNING/PoolWorker-1] 8
[2017-02-01 17:08:55,576: INFO/MainProcess] Terminating 9f6f5f7a-8e74-4c6a-be8c-ac773042ab0d (Signals.SIGTERM)
[2017-02-01 17:08:55,582: WARNING/MainProcess] {'request': <Request: app.test[9f6f5f7a-8e74-4c6a-be8c-ac773042ab0d] () {}>, 'signal': <Signal: task_revoked providing_args={'request', 'expired', 'terminated', 'signum'}>, 'sender': <@task: app.test of app:0x10b3f5400>, 'signum': <Signals.SIGTERM: 15>, 'expired': False, 'terminated': True}
[2017-02-01 17:08:55,582: WARNING/MainProcess] task_revoked
[2017-02-01 17:08:55,596: WARNING/MainProcess] {'request': <Request: app.test[9f6f5f7a-8e74-4c6a-be8c-ac773042ab0d] () {}>, 'signal': <Signal: task_revoked providing_args={'request', 'expired', 'terminated', 'signum'}>, 'sender': <@task: app.test of app:0x10b3f5400>, 'signum': '15', 'expired': False, 'terminated': True}
[2017-02-01 17:08:55,596: WARNING/MainProcess] task_revoked
[2017-02-01 17:08:55,596: ERROR/MainProcess] Task handler raised error: Terminated(15,)
Traceback (most recent call last):
File "/Users/jdepoix/Temp/celery_test/virtualenv/lib/python3.5/site-packages/billiard/pool.py", line 1726, in _set_terminated
raise Terminated(-(signum or 0))
billiard.exceptions.Terminated: 15