Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override Task.apply() to support eager running of Batches #16

Merged
merged 2 commits into from
Jan 28, 2020
Merged

Override Task.apply() to support eager running of Batches #16

merged 2 commits into from
Jan 28, 2020

Conversation

scalen
Copy link
Contributor

@scalen scalen commented Dec 10, 2019

Prior to this change, eager running of batches caused errors whereby
the batched task was passed the args and kwargs directly, rather than
wrapping them as a request, when the following was called:
.apply_async(args, kwargs, *_args, **_kwargs)

This change updates the minumum viable version of celery, and overrides
the new Task.apply() method to pass the request wrapped in a
SimpleRequest and a list to the underlying function when in eager mode.

requirements/default.txt Outdated Show resolved Hide resolved
@clokep clokep self-requested a review December 10, 2019 16:44
@clokep
Copy link
Owner

clokep commented Dec 11, 2019

On the surface this change looks pretty reasonable. I'll need to compare it with the implementation of a "normal" task and see if it will break at all.

Any way of adding a test for this?

@scalen
Copy link
Contributor Author

scalen commented Dec 11, 2019 via email

@clokep
Copy link
Owner

clokep commented Dec 11, 2019

Pretty much. The current ones are a little weird cause they run a separate worker in a different thread, I think. Which shouldn't be necessary for an eager task though!

@scalen
Copy link
Contributor Author

scalen commented Dec 11, 2019 via email

celery_batches/__init__.py Outdated Show resolved Hide resolved
@scalen
Copy link
Contributor Author

scalen commented Jan 6, 2020

Hi @clokep, do you know if there is likely to be any move to merge this at some point? (just reflagging in case it has been forgotten, I apologise if there is some process this is moving through outside of GitHub).

@clokep
Copy link
Owner

clokep commented Jan 9, 2020

@scalen Sorry for the delay! Lost track of this over the holidays. I'll try to get to this "soon". 😄 Please feel free to ping me again if you don't hear back soon!

I think the code looks pretty good, but I wanted to test this in our development environment first to make sure the change of the base task doesn't break anything.

@scalen
Copy link
Contributor Author

scalen commented Jan 9, 2020 via email

celery_batches/__init__.py Outdated Show resolved Hide resolved
Prior to this change, eager running of batches caused errors whereby
the batched task was passed the args and kwargs directly, rather than
wrapping them as a request, when the following was called:
`.apply_async(args, kwargs, *_args, **_kwargs)`

This change updates the minumum viable version of celery, and overrides
the new `Task.apply()` method to pass the request wrapped in a
`SimpleRequest` and a `list` to the underlying function when in eager mode.
@clokep
Copy link
Owner

clokep commented Jan 28, 2020

Something shook loose while reviewing this again and I realized I had worked on this previously! See 80609f8 for what I had come up with. It is very similar, but I think the key you unlocked was inheriting from the correct Task class!

I'm testing this out, but I think it looks good overall! 👍

@clokep
Copy link
Owner

clokep commented Jan 28, 2020

OK! This looks good. I have a couple of commits to add, but GitHub is complaining about me pushing to your branch, so I'll add them on top afterward.

@clokep clokep merged commit be817fd into clokep:master Jan 28, 2020
@clokep
Copy link
Owner

clokep commented Jan 28, 2020

See #18 for the changes I made.

clokep added a commit that referenced this pull request Jan 28, 2020
Minor clean-ups to eager code path (PR #16)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants