Mentions légales du service

Skip to content

Improve `run_as_processes` to capture exceptions and outputs.

ANDREY Paul requested to merge improve-multiprocessing into develop

This MR substantially modifies the backend and return signature of declearn.test_utils.run_as_processes.

The changes implemented are the following:

  • Add exceptions and outputs catching to multiprocessed routines.
  • Change the output signature of run_as_processes to return a bool flag indicating success, and a list of routine-wise output value or RuntimeError (that may either result from an actual failure or from the process having been interrupted due to another one's failure).
  • Add auto_stop parameter to enable disabling the default automated interruption of processes once any of them has failed.

The tests and examples that use that function have also been updated accordingly.

While no dedicated unit tests were written (due to the function belonging to the developers-only declearn.test_utils), some may be in the future, notably if the util is moved to the public declearn.utils module. Locally, the exception-catching behavior has been tested to work properly, and the Heart-UCI example and tests have been run in cases that voluntarily failed to assess that the outputs, while heavy at times, provided with the expected traceback information in case of failure.

Note that an additional effort was done to try and have coverage statistics' collection work within the spawned and run processes; however, until now, no attempt has been successful. Edit: the latter point was finally achieved, without having to alter the code of run_as_processes, but merely by configuring the coverage tool. It will therefore be the topic of a distinct MR.

Edited by ANDREY Paul

Merge request reports