suzieq icon indicating copy to clipboard operation
suzieq copied to clipboard

Poller: handle multiple exceptions

Open LucaNicosia opened this issue 2 years ago • 2 comments

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

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

LucaNicosia avatar Jan 31 '23 17:01 LucaNicosia

Can this be merged?

ryanmerolle avatar Jun 19 '24 13:06 ryanmerolle

Can this be merged?

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

ddutt avatar Jun 19 '24 14:06 ddutt