Repository navigation
Conversation
Add a __nonzero__ check that only consumes one item. Add a __repr__ that does not consume any items.
Prior to this change, if a generator was passed to group or chord it was completely expanded prior to any tasks being submitted to the backend. After this change, tasks will be submitted to the backend as they are retreived from the generator, allowing work to begin much sooner for long-running generators. This is currently a work in progress: only redis is supported.
|
Do the tests already cover this usecase? |
@thedrow no they don't. I haven't added any new tests, but I plan to once I get a nod of approval on the general idea from @ask or another maintainer (is there another maintainer?). Any help I could get on implementing the feature for the other backends would be appreciated as well. |
|
I'm also maintaining the project but I never used celery with redis so I'm not familiar with that part of the code. |
|
@thedrow Can you weigh in on how this might be done for the other backends? If they were completed, do you see any reason not to merge this PR? |
|
I don't see any reason why this shouldn't be merged. It just requires tests. |
|
I'm getting pretty close to having all the tests working, but for now I've decided to only support this feature for redis. It seems like the other backends require that all tasks be submitted immediately to allow the Before I can finish this, I have three questions:
Generally it seems there are a lot of different ways to do the same thing in the celery code and few comments to explain whether the subtle differences are intentional or not. Last note, |
|
sorry, one more:
def _prepared(self, tasks, partial_args, group_id, root_id, app, dict=dict,
CallableSignature=abstract.CallableSignature,
from_dict=Signature.from_dict):There is nowhere within the celery code that uses these arguments, and no comment explaining this bizarre behavior. And in fact, the |
|
I'm not familiar enough with the project so I'm assigning this to @ask to answer your questions. |
…ator is exhausted.
…nd and add tests.
Current coverage is
|
…ckend.set_chord_size
only the cache backend
In the case of
I would guess this is because
Do you have any examples of this? In general comments related to the code in the function only,
I'd guess this is something leftover from when all signatures had a builtin task.
It's localizing globals that are used within the loop, as for every iteration Python needs to Usually small savings, but it's used a lot in the worker inner loop (together with inlining), the end result Another reason for doing this is for threads, since when threads wake up during interpreter shutdown |
| if self.__done: | ||
| return repr(self.__consumed) | ||
| else: | ||
| return '[{}]'.format(', '.join( |
There was a problem hiding this comment.
Please use {0} here, as position-less format is not supported by all 2.7 versions
|
Btw, I like your changes here. I'm not sure I have understood all of them yet as I just looked at it briefly, maybe you could add some comments to describe what's happening in regen? Good idea putting the length of the chord into redis, that totally makes sense since it's the only result backend that actually needs it. I guess you can also remove _traverse_result and length_hint, since they are not used anymore. I think one problem with using set_chord_size separately is that it complicates error handling, and this is maybe something that we should think about as currently everything depends on that operation actually succeeding, and there is no retry or anything. |
|
I.e. If the set_chord_size fails we should probably retry, and on giving up it would need to set an error status for the chord? |
|
Oh, |
|
Hi @ask |
|
I tried to merge this into master, but I have been unable to get the tests to pass so far. The work is in the canvas-generator branch, commit: 23abf35 Need to postpone this to 4.1 for now as need to continue with getting 4.0 release out. |
|
I have my hands pretty full with other side projects at the moment, and I don't actually need this feature any more as I've taken a different approach in my project, but it'd be cool to have that little "Contributor" tag next to my name when I post issues here, so.... I may be able to find some time to give it a go :) @ask Any chance you can push the merge you did? It would save me some time. |
|
I am going to make it work on master. but you will definitely get the credit |
|
Deal ;)
let me know if you need any help once you get it merged / rebased against
master.
…On Thu, Dec 21, 2017 at 7:40 AM Asif Saifuddin Auvi < ***@***.***> wrote:
I am going to make it work on master. but you will definitely get the
credit
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3043 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAD3E5_GmdH-emrtyB9i3Dt5PvZ2XEFCks5tCnvZgaJpZM4HU-oI>
.
|
|
re base seems problematic, so I am trying to implement it cleanly step by step with smaller chunks. could you review it #4459 here later? might need your suggestions about testing part |
|
closing in favor of new patch |
When passing a generator to
grouporchord, sub-tasks are not submitted to the backend for execution until the entire generator is consumed. The expected result is that subtasks are submitted during iteration, as soon as they are yielded. This can have a big impact on performance if generators yield subtasks over a long period of time.I also opened issue #3021 on the subject. This explanation from @Eli-Green I think is pretty on point.
So far I've only added support for redis. I started looking at the other backends but I ran out of time. It would be great to get some feedback on what I have so far and to get some thoughts on how difficult it will be to add for the other backends.