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

Are exceptions sent to the parent twice? #626

Open
cortadocodes opened this issue Feb 6, 2024 · 1 comment
Open

Are exceptions sent to the parent twice? #626

cortadocodes opened this issue Feb 6, 2024 · 1 comment

Comments

@cortadocodes
Copy link
Member

Bug report

What is the current behavior?

Service.send_exception is possibly called in both answer_pub_sub_question and Service.answer if an error is raised during question is being answered. We should find out whether exception messages are in fact being sent to the parent twice.

What is the expected behavior?

Exception messages should be sent once only.

Proposed Solution

Possibly eliminate one of the calls of the method.

@cortadocodes
Copy link
Member Author

We previously had this code in a django-twined private app that would be triggered if a result message was received but the child then raised an exception:

# TODO: REFACTOR REQUEST Refactor this signal handler once exceptions from the octue service
# are correctly handled.
# Exceptions are sent from a service after the analysis has been finalised resulting in the service
# having an answer but marked failed. Don't update question status as failed if it has an answer.
@receiver(exception_received, sender=ServiceUsageEvent)
def update_question_status(sender, service_usage_event, **kwargs):
    logger.info("Exception received for question %s", service_usage_event.question_id)
    question = service_usage_event.question.as_subclass()

    # check to prevent completed questions with answer being set to failed
    # due to an exception being sent after the answers have been finalised.
    if not question.output_values:
        question.calculation_status = ERROR_STATUS
        question.save()

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

No branches or pull requests

1 participant