Instead of putting one timeout of 2 sec at the beginning of the check for the loop devices, use the already existing timeout implementation inside the loop and just increase the maximum timeout to 60 sec. This improves the overall behavior, because as soon as the loop devices are detected, the loop will be exited, but it also increases the maximum possible time to wait for the loop devices. This is helpful when being used on slower systems.
Instead of putting one timeout of 2 sec at the beginning of the check for the loop devices, use the already existing timeout implementation inside the loop and just increase the maximum timeout to 60 sec. This improves the overall behavior, because as soon as the loop devices are detected, the loop will be exited, but it also increases the maximum possible time to wait for the loop devices. This is helpful when being used on slower systems.