Stop all workers and quit if one task fails


Im developing an application to reach out to devices, interact with some CLI commands, save output to a file in a directory specified in a config file, and quit.

Im having a problem with error handling that usually is very simple to handle in python, but with Nornir multithreading things got a little complicated.

I need to stop executing the code (and all threads) in case the specified directory does not exist. The problem is I can stop the task, but all other tasks continue executing until all the inventory is worked out. All of them are failing and workers quit, but still the entire inventory is worked.

Is there any known way to stop nornir at all in case any of the tasks fail?

Thank you.