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 tasks into decorators #4666

Merged

Conversation

@stsewd
Copy link
Member

@stsewd stsewd commented Sep 26, 2018

Closes #3973

This will also helps with #3984 later

step = UpdateDocsTaskStep(task=self)
return step.run(*args, **kwargs)
@app.task(bind=True, max_retries=5, default_retry_delay=7 * 60)
def update_docs_task(self, project_id, *args, **kwargs):
Copy link
Member Author

@stsewd stsewd Sep 26, 2018

Choose a reason for hiding this comment

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

Pylint doesn't like binded task, the self parameter gets injected by the decorator.

Loading

tasks.SyncRepositoryTask().run(
version.pk,
)
tasks.sync_repository_task(version.pk)
Copy link
Member Author

@stsewd stsewd Sep 26, 2018

Choose a reason for hiding this comment

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

I assume that calling directly to run is the same as executing the task on the same host.

Loading

Copy link
Contributor

@agjohnson agjohnson Oct 2, 2018

Choose a reason for hiding this comment

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

Yeah, this should be equal

Loading

@stsewd
Copy link
Member Author

@stsewd stsewd commented Sep 26, 2018

I think this is ready, we can refactor more: classes aren't needed here, we can refactor those to be just functions. Let me know if you want me to do that here, or maybe we can do it in another PR.

Also, I tested with some builds locally (also some commands), it works.

Loading

Copy link
Contributor

@agjohnson agjohnson left a comment

Another nice clean refactor 👍

I did a quick scan on our commercial hosting code, and I don't think we rely on any of the classes here. This probably won't break things, but we'll need some QA here as well.

Loading

tasks.SyncRepositoryTask().run(
version.pk,
)
tasks.sync_repository_task(version.pk)
Copy link
Contributor

@agjohnson agjohnson Oct 2, 2018

Choose a reason for hiding this comment

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

Yeah, this should be equal

Loading

@stsewd
Copy link
Member Author

@stsewd stsewd commented Oct 2, 2018

Looks like need to fix some linter errors

Loading

@agjohnson
Copy link
Contributor

@agjohnson agjohnson commented Oct 2, 2018

Yeah i think in part due to my resolve. Seems to be okay now though

Loading

@agjohnson agjohnson merged commit a984417 into readthedocs:master Oct 2, 2018
1 check passed
Loading
@stsewd
Copy link
Member Author

@stsewd stsewd commented Oct 2, 2018

Error fixed, it was because of #4653

Loading

@stsewd stsewd deleted the refactor-project-tasks-to-decorators branch Oct 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants