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

Refactor PublicTask into a decorator task #4656

Merged
merged 2 commits into from
Oct 2, 2018

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Sep 21, 2018

Still wip, I need to update some docstrings, but I already tested it, and it works :)

Fix #3974 and ref to #3973

@stsewd stsewd added the PR: work in progress Pull request is not ready for full review label Sep 21, 2018
user = User.objects.get(pk=user_id)
for service_cls in registry:
for service in service_cls.for_user(user):
service.sync()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The api for defining a public task is cleaner now :D

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much nicer!

@@ -22,20 +31,12 @@


@permission_check(user_id_matches)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the celery docs, it says that we shouldn't do this (put the task decorator down), but the task decorator overrides all function's attributes and deletes the added by permission_check, this way we can keep the added attribute.

@stsewd
Copy link
Member Author

stsewd commented Sep 21, 2018

I believe this is ready, I also tested it locally, it works as expected.

@stsewd stsewd removed the PR: work in progress Pull request is not ready for full review label Sep 21, 2018
@stsewd stsewd requested a review from a team September 21, 2018 17:35
Copy link
Contributor

@agjohnson agjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! We'll want to make sure this has some QA before release, but I don't think we use public task anywhere else at the moment.

user = User.objects.get(pk=user_id)
for service_cls in registry:
for service in service_cls.for_user(user):
service.sync()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much nicer!

@agjohnson agjohnson merged commit a8bd00a into readthedocs:master Oct 2, 2018
@stsewd stsewd deleted the refactor-public-task branch October 2, 2018 17:34
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