Issue 1:
Expected Behavior

Catch billiard.exceptions.Terminated and don't throw any error.

Actual Behavior

As the title says billiard.exceptions.Terminated exception is not caught even when it is defined in throws argument of celery task decorator.

Steps to Reproduce

Minimally Reproducible Test Case

I created a file celery_test.py

import time

from celery import Celery
from billiard.exceptions import Terminated

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

@app.task(throws=(Terminated, ))
def task():
time.sleep(50)

if __name__ == "__main__":
task_id = task.delay().id
app.control.revoke(task_id, terminate=True)

Then I ran a worker like this:

$ celery -A celery_test worker -l INFO -n test_worker

It returned:

[2019-08-29 14:41:14,384: INFO/MainProcess] Connected to amqp://guest:**@127.0.0.1:5672//
[2019-08-29 14:41:14,395: INFO/MainProcess] mingle: searching for neighbors
[2019-08-29 14:41:15,419: INFO/MainProcess] mingle: all alone
[2019-08-29 14:41:15,439: INFO/MainProcess] celery@test_worker ready.
[2019-08-29 14:41:16,770: INFO/MainProcess] Received task: celery_test.task[e6d6383e-2610-44bb-99fa-ed97f8ff309c]
[2019-08-29 14:41:16,852: INFO/MainProcess] Terminating e6d6383e-2610-44bb-99fa-ed97f8ff309c (Signals.SIGTERM)
[2019-08-29 14:41:16,865: ERROR/MainProcess] Task handler raised error: Terminated(15,)
Traceback (most recent call last):
File "/home/jozef/.pyenv/versions/3.6.5/lib/python3.6/site-packages/billiard/pool.py", line 1769, in _set_terminated
raise Terminated(-(signum or 0))
billiard.exceptions.Terminated: 15

Python Packages

alembic==1.0.10

amqp==2.5.1

anyjson==0.3.3

arrow==0.12.1

asn1crypto==0.24.0

Babel==2.5.1

bcrypt==3.1.6

beautifulsoup4==4.6.0

billiard==3.6.1.0

cached-property==1.4.0

cachetools==2.0.0

celery==4.3.0

certifi==2018.1.18

cffi==1.12.1

chardet==3.0.4

Click==7.0

cryptography==2.5

decorator==4.3.2

docopt==0.6.2

docopt-dispatch==0.0.2

elasticsearch==6.3.1

emoji==0.4.5

eventlet==0.22.1

Fabric3==1.14.post1

Flask==0.12.4

flower==0.8.1

graypy==0.2.14

greenlet==0.4.15

gspread==3.1.0

gunicorn==19.7.1

httplib2==0.12.1

idna==2.7

ijson==2.3

importlib-metadata==0.19

itsdangerous==0.24

Jinja2==2.10

jsonpath-ng==1.4.3

kombu==4.6.4

lxml==4.1.1

Mako==1.0.7

MarkupSafe==1.1.0

minio==3.0.3

more-itertools==7.2.0

oauth2client==4.1.3

ordered-set==3.1.1

ordereddict==1.1

paramiko==2.4.2

pika==0.11.2

pipenv==2018.11.26

ply==3.11

prometheus-client==0.3.1

psutil==5.4.3

psycopg2==2.8.3

pyasn1==0.4.5

pyasn1-modules==0.2.4

pycparser==2.19

pycryptodomex==3.6.6

PyJWT==1.6.4

PyNaCl==1.3.0

pyrabbit==1.1.0

pysftp==0.2.8

python-dateutil==2.8.0

python-editor==1.0.4

python-magic==0.4.12

pytz==2018.3

redis==2.10.6

requests==2.20.0

rsa==4.0

simplejson==3.11.1

six==1.12.0

SQLAlchemy==1.2.5

SQLAlchemy-Utils==0.33.1

tld==0.7.9

tornado==5.1.1

uhashring==0.8

Unidecode==0.4.21

urllib3==1.24.1

vine==1.3.0

virtualenv==16.6.0

virtualenv-clone==0.5.3

voluptuous==0.11.1

Werkzeug==0.14.1

WooCommerce==1.2.1

zipp==0.6.0

Celery report

software -> celery:4.3.0 (rhubarb) kombu:4.6.4 py:3.6.5
billiard:3.6.1.0 py-amqp:2.5.1
platform -> system:Linux arch:64bit
kernel version:4.15.0-58-generic imp:CPython
loader -> celery.loaders.app.AppLoader
settings -> transport:amqp results:disabled

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

Similar issues:

#2727

Issue 2:
[2015-07-27 12:52:38,386: ERROR/MainProcess] Task myapp.tasks.test [150a75dc-592e-4c0c-b686-1cc5aaf5a168] raised unexpected: Terminated(15,)

Traceback (most recent call last):

File "/home/blake/projects/venv/myapp/lib/python2.7/site-packages/billiard/pool.py", line 1674, in _set_terminated

raise Terminated(-(signum or 0))

Terminated: 15

packages installed:

amqp==1.4.6

anyjson==0.3.3

beautifulsoup4==4.4.0

billiard==3.3.0.20

celery==3.1.18

Django==1.7.7

django-celery==3.1.16

django-pipeline==1.5.2

futures==3.0.3

kombu==3.0.25

pytz==2015.4

redis==2.10.3

requests==2.7.0

wheel==0.24.0

I'm starting worker with:

celery -A myapp worker --loglevel=INFO --concurrency=10

i'm revoking with:

from celery.task.control import revoke

revoke(task_id, terminate=True, signal='SIGKILL')

is this the wrong approach?