Open jie8357IOII opened 4 years ago
I use celery==5.0.0, pymongo==3.11.2, mongodb==4.4.2 .And I just replace the code line 205 of celery/celery/backends/mongodb.py with
'traceback': obj['traceback'],
and it works now but I don't know whether it will have side effects.
Please provide a reproducible test case. I can't help you without reproducing the issue myself.
Please provide a reproducible test case. I can't help you without reproducing the issue myself.
Thanks for your attention.By the way, python==3.6.8 @thedrow
consumer tasks.py
from time import sleep
from celery import Celery
app = Celery('tasks', backend='mongodb://172.17.0.10:27017/celery_data', broker='pyamqp://172.17.0.11:5672',
# include=['dist_tasks.tasks']
)
@app.task
def sub(x: int, y: int):
for i in range(10):
sleep(0.5)
return x - y
productor client_demo.py
from time import sleep
from celery import Celery, exceptions
app = Celery('tasks', backend='mongodb://172.17.0.10:27017/celery_data', broker='pyamqp://172.17.0.11:5672',)
def test_case():
result = app.send_task('tasks.sub', kwargs={'x': 3, 'y': '4'})
# I change the y from int to string to call the exception
sleep(2)
# print(result.ready())
print(result.id, result.status, result.result)
ret = result.get(timeout=15) # exception here
if __name__ == '__main__':
test_case()
exception
Traceback (most recent call last):
File "/mnt/venv4fastapi/lib/python3.6/site-packages/kombu/serialization.py", line 49, in _reraise_errors
yield
File "/mnt/venv4fastapi/lib/python3.6/site-packages/kombu/serialization.py", line 262, in loads
return decode(data)
File "/mnt/venv4fastapi/lib/python3.6/site-packages/kombu/utils/json.py", line 85, in loads
return _loads(s)
File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)```
Checklist
master
branch of Celery.Mandatory Debugging Information
celery -A proj report
in the issue. (if you are not able to do this, then at least specify the Celery version affected).master
branch of Celery.pip freeze
in the issue.Optional Debugging Information
Related Issues and Possible Duplicates
Related Issues
6258
6259
Possible Duplicates
Environment & Settings
Celery version:
celery report
Output:``` ```
Steps to Reproduce
Required Dependencies
Python Packages
pip freeze
Output:``` ```
Other Dependencies
N/A
Minimally Reproducible Test Case
```python ```
Expected Behavior
It will return a result when the task finished. And it should return the trace log or task state when the task failed.
Actual Behavior
When we try to get the failed task trace log or state, it will be failed because it tries to decode variable without encoding...
I think the following code is why the error happens.
The full log is here.