Repository navigation
Closed
Milestone
Description
Version: celery==4.1.0
$ celery -A poc worker --loglevel=info
-------------- [email protected] v4.1.0 (latentcall)
---- **** -----
--- * *** * -- Darwin-16.7.0-x86_64-i386-64bit 2018-05-16 17:42:08
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app: poc:0x10287fc18
- ** ---------- .> transport: redis://localhost:6379/0
- ** ---------- .> results: redis://localhost:6379/0
- *** --- * --- .> concurrency: 12 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
-------------- [queues]
.> celery exchange=celery(direct) key=celery
[tasks]
. poc.add
Celery worker runs fine, issue seems to be when the graph is built with build_graph().
Traceback (most recent call last):
File "/Users/user/.pyenv/versions/3.6.1/envs/3.6.1-celery-poc/lib/python3.6/site-packages/kombu/utils/objects.py", line 42, in __get__
return obj.__dict__[self.__name__]
KeyError: 'graph'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "poc.py", line 33, in <module>
root.graph.to_dot(fh)
File "/Users/user/.pyenv/versions/3.6.1/envs/3.6.1-celery-poc/lib/python3.6/site-packages/kombu/utils/objects.py", line 44, in __get__
value = obj.__dict__[self.__name__] = self.__get(obj)
File "/Users/user/.pyenv/versions/3.6.1/envs/3.6.1-celery-poc/lib/python3.6/site-packages/celery/result.py", line 354, in graph
return self.build_graph()
File "/Users/user/.pyenv/versions/3.6.1/envs/3.6.1-celery-poc/lib/python3.6/site-packages/celery/result.py", line 314, in build_graph
graph.add_arc(node)
File "/Users/user/.pyenv/versions/3.6.1/envs/3.6.1-celery-poc/lib/python3.6/site-packages/celery/utils/graph.py", line 53, in add_arc
self.adjacent.setdefault(obj, [])
TypeError: unhashable type: 'GroupResult'
Steps to reproduce
import celery
from celery.canvas import group, chain
app = celery.Celery('poc')
app.conf.update(
task_serializer='json',
accept_content=['json'],
result_serializer='json',
enable_utc=True,
broker_url = 'redis://localhost:6379/0',
result_backend = 'redis://localhost:6379/0'
)
@app.task
def add(x, y):
return x + y
if __name__ == '__main__':
res = chain(add.si(1,1), group(add.si(2,2), add.si(3,3), add.si(4,4)))()
res.get()
# Find root result of graph
root = res.parent
while root.parent is not None:
root = root.parent
with open('graph.dot', 'w') as fh:
root.graph.to_dot(fh)
Expected behavior
Generate the dotfile as expected by transforming each list item task id into a node entity with a corresponding arc for the graph.
Actual behavior
Error shown above.
Disclaimer: I am brand new to celery.
Activity
[-]Unable to generate dotfile: to_dot() unhashable type: 'GroupResult'[/-][+]Unable to build_graph() unhashable type: 'GroupResult'[/+]auvipy commentedon May 22, 2018
does celery 4.2rc4 remove this error?
faffi commentedon May 22, 2018
Hi auvipy,
4.2rc4 does not remove the error. Snippets below.
georgepsarakis commentedon May 23, 2018
@faffi I believe the error is caused because build_graph does not iterate over the results of a
GroupResult. Perhaps the solution would be:xirdneh commentedon Jun 2, 2018
@georgepsarakis I think
build_graphdoes loop through aResultSetchildren.build_graphcallsiterdepswhich waits for each result to finish and if the result has any children it adds each children to the stack to be yield.The
TypeErroris raised when the graph tries to add aGroupResultas a node becauseGroupResultdoes not have a__hash__method implemented.I added a
__hash__method and did a quick test and I can verify the graph is created correctly.Writing tests...
thedrow commentedon Jun 3, 2018
@xirdneh Good job.
You marked this issue as
Needs Testcasebut a test case was provided.There is a label for
Has Testcase.thedrow commentedon Jun 3, 2018
Since this happened in Celery 4.1 I do not consider this a blocker for releasing 4.2.
@xirdneh If you can fix it in the next couple of days, I'll merge it and we'll call it GA.
If a fix is not provided, we'll release anyway.