Export time out avoidance
Sites have a php time out to prevent long running processes & out of control loops. However, there are some processes that are known to need more time that others & we can extend the timeout within php to keep them alive. This is pretty safe because it's within a loop so we extend a little each row rather a huge time extension
Basically we can check each iteration here & if less than 10 seconds remains we can add 10 seconds as a sort of heartbeat https://www.php.net/manual/en/function.set-time-limit.php