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

Added support for requests that contain an ETA datetime in the future #59

Merged
merged 19 commits into from
Apr 27, 2022

Conversation

weetster
Copy link
Contributor

Hello,

I'm using celery-batches for a project that requires failed tasks to be retried at a later time (for example, if a web API request fails). I documented the approach that I was hoping to use in the case of failure and retry (apply_async(countdown=10)) in this pull request, which was inspired by the discussion in issue #10. I noticed that the approach did not work, because [email protected] does not handle Celery Request objects that have an .eta field. I've added support to celery-batches for handling this scenario, and I hope that you will consider merging my changes into the main branch for inclusion in an upcoming 0.7 release.

Thank you.

@weetster weetster requested a review from clokep as a code owner March 22, 2022 18:53
@clokep
Copy link
Owner

clokep commented Mar 22, 2022

Thanks! Will try to take a look soon! 👍

@clokep
Copy link
Owner

clokep commented Mar 22, 2022

Looks like there's a couple of lint errors, could you run flake8 (or take a look at the CI output) and fix those up? Thanks!

docs/index.rst Outdated Show resolved Hide resolved
celery_batches/__init__.py Outdated Show resolved Hide resolved
celery_batches/__init__.py Outdated Show resolved Hide resolved
@weetster
Copy link
Contributor Author

Hey, thanks for the code review. I just noticed it now, since it was posted the same day that I left for a week-long vacation. I'll take a look at addressing the comments as soon as I can.

@clokep
Copy link
Owner

clokep commented Apr 12, 2022

Hey, thanks for the code review. I just noticed it now, since it was posted the same day that I left for a week-long vacation. I'll take a look at addressing the comments as soon as I can.

No problem! Do let me know if you have any questions or disagree with any of the comments. I think I also bitrotted this PR decently by adding type hints, sorry about that. 😢 Hopefully they make it a bit easier to see what's going on though!

@clokep clokep self-requested a review April 14, 2022 14:56
@clokep
Copy link
Owner

clokep commented Apr 14, 2022

I need to document this, but you should be able to do the following to run the lint checks:

$ pip install -r requirements/pkgutils.txt
$ flake8
$ isort
$ black
$ mypy

(And don't worry about random extra commits -- we'll squash merge anyway.)

celery_batches/__init__.py Outdated Show resolved Hide resolved
t/integration/tasks.py Outdated Show resolved Hide resolved
t/integration/tasks.py Outdated Show resolved Hide resolved
celery_batches/__init__.py Outdated Show resolved Hide resolved
@weetster
Copy link
Contributor Author

I was just making fixes for the workflow, didn't see your new comments until now. Thanks, will take a look!

@weetster
Copy link
Contributor Author

All set for another look. Thanks again!

@clokep
Copy link
Owner

clokep commented Apr 20, 2022

@weetster This is back to you, note that if you can't get the tests to run with live brokers yet, we can skip it. I think there's something flakey with returning results in those cases. (You can see they skip another test also...)

@weetster
Copy link
Contributor Author

@weetster This is back to you, note that if you can't get the tests to run with live brokers yet, we can skip it. I think there's something flakey with returning results in those cases. (You can see they skip another test also...)

Thanks, the tests work well on my local machine, so I added a skip similar to the other test case that you mentioned.

@clokep clokep self-requested a review April 21, 2022 11:45
docs/index.rst Outdated Show resolved Hide resolved
@clokep
Copy link
Owner

clokep commented Apr 21, 2022

If it is easier I can make the remaining changes and push them to your branch (I think I have the right permissions to do that...)

@weetster
Copy link
Contributor Author

If it is easier I can make the remaining changes and push them to your branch (I think I have the right permissions to do that...)

Sure, that's ok with me, if it's easier for you to make the changes to how you want it. Let me know if there's anything else I should do. 👍

@clokep clokep self-requested a review April 25, 2022 12:31
@clokep
Copy link
Owner

clokep commented Apr 26, 2022

@weetster I pushed a few commits to:

  • Update the tests a bit like we discussed.
  • Update the documentation (to be more inline with other changes on main).
  • Properly handle timezones (mostly be copying the behavior inside of Celery's default strategy).

Does this all look reasonable to you? If you could give it a quick test and make sure it still works for you I would appreciate it! 👍 The current release already has a lot in it so would like to include this and then get it out the door. :shipit:

@weetster
Copy link
Contributor Author

@clokep Thanks for the extra commits, good to handle timezones properly. celery-batches unit tests pass for me, and my project that relies on celery-batches also passes its unit tests with the latest changes. Looks good to me for a release.

@clokep clokep merged commit 49b6ee3 into clokep:main Apr 27, 2022
@clokep
Copy link
Owner

clokep commented Apr 27, 2022

Thanks for checking! 🎉 (And for making this PR!)

I plan to do a new release soon!

@weetster
Copy link
Contributor Author

You're welcome, and thanks for accepting the changes! They will be a huge help to me and hopefully others.

rammie pushed a commit to rammie/celery-batches that referenced this pull request Apr 29, 2023
)

Allow Batches tasks to be called with `apply_async(..., eta=...)` or
`apply_async(..., countdown=...)`.
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