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

Poller: handle multiple exceptions #851

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

LucaNicosia
Copy link
Collaborator

Description

The entire code of the controller and the workers leverage on asyncio tasks.

In the current version of the code, if one of the task was raising an exception, we fail right away and re-raise the exception letting the core method of the SuzieQ components handle the exception.
It may happen that more than one task raise an exception: in this case, since we raise an exception as soon as we see one, the other exceptions are not handled.
For these exceptions, asyncio complains with the message Task exception was never retrieved (see python docs) and re-raise the exceptions, but since the main code of the SuzieQ component is already ended, the exception is not handled and the traceback is printed on the log generating a confusing output.

To fix this issue, it is introduced a new exception class called SqRuntimeError which contains a list of exceptions.
In the code of the controller and the worker, instead of raising the exception as soon as we see a task failing, we collect all the exception in an array. If this array is not empty, we use this array to initialize a SqRuntimeError exception and we raise this exception.
The main code of the controller (sq_poller.py) and the worker (sq_worker.py) will verify if the type of the exception is SqRuntimeError and if so, log each exception in the exception list.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Double Check

  • I have read the comments and followed the CONTRIBUTING.md.
  • I have explained my PR according to the information in the comments or in a linked issue.
  • My PR source branch is created from the develop branch.
  • My PR targets the develop branch.
  • All my commits have --signoff applied

Signed-off-by: LucaNicosia <luca.nicosia@stardustsystems.net>
Signed-off-by: LucaNicosia <luca.nicosia@stardustsystems.net>
Signed-off-by: LucaNicosia <luca.nicosia@stardustsystems.net>
Signed-off-by: LucaNicosia <luca.nicosia@stardustsystems.net>
@ryanmerolle
Copy link
Contributor

Can this be merged?

@ddutt
Copy link
Member

ddutt commented Jun 19, 2024

Can this be merged?

Yes, we'll work on getting this done for a possible end-of-month release

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.

5 participants