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

Stop Tasks and include exception message #31

Merged
merged 2 commits into from
Apr 27, 2020

Conversation

oisinBates
Copy link
Contributor

I wanted the ability to stop my tasks and pass an exception message while doing so.
This pull request facilitates that functionality.

I also updated the README file.

Copy link
Owner

@czue czue left a comment

Choose a reason for hiding this comment

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

Looks good, just one question before I approve/merge it in. Thanks for the feature!

@@ -68,7 +68,7 @@ def get_info(self):
'complete': True,
'success': success,
'progress': _get_completed_progress(),
'result': self.result.get(self.task_id) if success else None,
'result': self.result.get(self.task_id) if success else str(self.result.info),
Copy link
Owner

Choose a reason for hiding this comment

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

is self.result.info guaranteed to exist? mostly just wondering if we need to worry about this raising an exception

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for considering my feature.

Here's the relevant section in the documentation (https://docs.celeryproject.org/en/stable/reference/celery.result.html):
image

If there's nothing set, self.result.info returns a None value, so str(None) will just return 'None'.
If it does throw an exception, the str() function should handle the string conversion also.

Copy link
Owner

Choose a reason for hiding this comment

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

perfect, thanks.

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.

None yet

2 participants