Issue 1:
Checklist

[ x] I have read the relevant section in the

contribution guide

on reporting bugs.

[ x] I have checked the issues list

for similar or identical bug reports.

[ x] I have checked the pull requests list

for existing proposed fixes.

[ x] 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).

[ x] 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

#4551 (comment)

Possible Duplicates

None

Environment & Settings

Celery version: 4.3.0:

celery report Output:

celeryworker_1 | [2019-09-30 12:10:16,485: INFO/MainProcess] Received task: django_dask.users.tasks.get_users_count[0b2cd4f1-e6a9-41af-974c-bd9a60ddc648]

Steps to Reproduce

Required Dependencies

Minimal Python Version: 3.6.6

Minimal Celery Version: 4.3.0

Minimal Kombu Version: Unknown

Minimal Broker Version: redis==3.3.8

Minimal Result Backend Version: N/A or Unknown

Minimal OS and/or Kernel Version: Docker image python:3.6.6

Minimal Broker Client Version: N/A or Unknown

Minimal Result Backend Client Version: N/A or Unknown

Install cookiecutter django with celery and add dask package. You can either add dask as a service in docker-compose or initiate a local cluster within the {app}/users/app.py

Minimally Reproducible Test Case

Expected Behavior

That I am able to further create subprocesses within the task by triggering dask within celery task.

Actual Behavior

I am trying to start subprocesses of scikit learn within a task of celery. I am aware that joblib will run it sequentially if it is already running in a process. Therefore, based on #4551 (comment), I have installed Dask and changed joblib parallel_backend to dask and run the below function one time normally; i.e. get_users_count() and another time with apply_async(); i.e., get_users_count.apply_async(). The former ran successfully and the later showed that the worker has received the message (as shown in the celery report above). and celery worker hangs and become unresponsive, I tried to access the worker in flower, however I received Unknown worker 'celery@0bb51b1f7782' as if it is died (which was previously accessible before calling the function).

@celery_app.task()
def get_users_count():
"""A pointless Celery task to demonstrate usage."""
from sklearn.utils import parallel_backend
import numpy as np
from sklearn.cluster import KMeans

parallel_backend("dask")
kmeans = KMeans(n_jobs=-1, n_init=5, verbose=10)
kmeans.fit(np.random.rand(1000).reshape(500, 2))

return User.objects.count()

Issue 2:
Checklist

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

error when get task state or other attribute value.

>>> taskid="d7b78dfa-5602-4a4e-bf4e-dff1c9a8e46e"
>>> task = TAA.AsyncResult(taskid)
>>>
>>> task.state
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/celery/result.py", line 473, in state
return self._get_task_meta()['status']
File "/usr/local/lib/python3.7/site-packages/celery/result.py", line 412, in _get_task_meta
return self._maybe_set_cache(self.backend.get_task_meta(self.id))
File "/usr/local/lib/python3.7/site-packages/celery/backends/base.py", line 386, in get_task_meta
meta = self._get_task_meta_for(task_id)
File "/usr/local/lib/python3.7/site-packages/celery/backends/base.py", line 730, in _get_task_meta_for
return self.decode_result(meta)
File "/usr/local/lib/python3.7/site-packages/celery/backends/base.py", line 305, in decode_result
return self.meta_from_decoded(self.decode(payload))
File "/usr/local/lib/python3.7/site-packages/celery/backends/base.py", line 301, in meta_from_decoded
meta['result'] = self.exception_to_python(meta['result'])
File "/usr/local/lib/python3.7/site-packages/celery/backends/base.py", line 281, in exception_to_python
exc = cls(*exc_msg if isinstance(exc_msg, tuple) else exc_msg)
TypeError: __init__() missing 2 required positional arguments: 'doc' and 'pos'

The content of the taskid task in redis:

{
"status": "FAILURE",
"result": {
"exc_type": "JSONDecodeError",
"exc_message": [
"Expecting ',' delimiter: line 1 column 528408 (char 528407)"
],
"exc_module": "json.decoder"
},
"traceback": "Traceback (most recent call last):\n File \"/usr/local/lib/python3.7/site-packages/celery/app/trace.py\", line 385, in trace_task\n R = retval = fun(*args, **kwargs)\n File \"/usr/local/lib/python3.7/site-packages/celery/app/trace.py\", line 648, in __protected_call__\n return self.run(*args, **kwargs)\n File \"/Users/youzhengchuan/PycharmProjects/collector/pcdn/analysis/__init__.py\", line 14, in telegraf_abnormal_analysis\n ret = taa.analysis(sts, ets, lot)\n File \"/Users/youzhengchuan/PycharmProjects/collector/pcdn/analysis/telegraf_abnormal_analysis.py\", line 42, in analysis\n online = self._query.groupby(**params)\n File \"/Users/youzhengchuan/PycharmProjects/collector/pcdn/analysis/query.py\", line 35, in groupby\n ret = self._query.groupby(**params)\n File \"/usr/local/lib/python3.7/site-packages/pydruid/client.py\", line 306, in groupby\n return self._post(query)\n File \"/usr/local/lib/python3.7/site-packages/pydruid/client.py\", line 571, in _post\n query.parse(data)\n File \"/usr/local/lib/python3.7/site-packages/pydruid/query.py\", line 53, in parse\n res = json.loads(self.result_json)\n File \"/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py\", line 348, in loads\n return _default_decoder.decode(s)\n File \"/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py\", line 337, in decode\n obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n File \"/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py\", line 353, in raw_decode\n obj, end = self.scan_once(s, idx)\njson.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 528408 (char 528407)\n",
"children": [],
"task_id": "d7b78dfa-5602-4a4e-bf4e-dff1c9a8e46e",
"date_done": "2019-09-04T08:11:17.388695"
}

None

Possible Duplicates

None

Environment & Settings

Celery version:

celery report Output:

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

Expected Behavior

Actual Behavior