Skip to content
New issue

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

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

Already on GitHub? # to your account

Hot-reload support to celery #2554

Merged
merged 6 commits into from
Dec 10, 2020
Merged

Conversation

yotamtal
Copy link

@yotamtal yotamtal commented Apr 21, 2020

Description

This PR adds support for celery hot-reloading while developing, on changes to tasks.py and celery_app.py files when setting up a project with docker and celery.

Rationale

I have been using this Cookiecutter template for many projects and while developing with celery tasks I had to restart the worker manually to test the changes. This minor change will allow developers to test their celery tasks faster

Use case(s) / visualization(s)

-> Develop celery tasks -> notice a bug -> change the code -> save -> test the new code without restarting the worker manually

@foarsitter
Copy link
Collaborator

Nice addition!

Is the pattern not to tight? Now the restarts do not happen when there are changes made to settings.py or models.py. So why not set it to *.py?

@yotamtal
Copy link
Author

@foarsitter I configured it that way on purpose, since I write all my tasks in those files.
I tried setting it as *.py before and then it restarts the worker on every save and the hot reload takes more time and mess up the logs, so I think this is the most efficient way to go :)

@browniebroke
Copy link
Member

browniebroke commented Apr 21, 2020

Nice addition indeed. Good question for the pattern, I'm not sure I understand the problem, but I probably just need to try it out 😄

@pySilver
Copy link

pySilver commented Apr 29, 2020

Nice work! Consider using watchgod instead of watchdog. Watchgod is used by uvicorn as an optional changes watcher, so it would solve both cases at the same time! :)

@scnerd
Copy link

scnerd commented Dec 9, 2020

This is a great feature idea. Is there anything still needed before this can be merged (besides simply resolving the merge conflicts)?

# Conflicts:
#	CONTRIBUTORS.rst
@browniebroke
Copy link
Member

Yes, I kind of forgot about it, I think it's good to go.

@browniebroke browniebroke merged commit 24a8c6d into cookiecutter:master Dec 10, 2020
@browniebroke
Copy link
Member

Thanks for your contribution @yotamtal 🎉

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants