// Close session to prevent session locking from waiting in case there is another request coming in
if($request->hasSession() && session_status() === \PHP_SESSION_ACTIVE){ $request->getSession()->save(); }
try{ $this->generateSitemap($context, true); }catch(AlreadyLockedException){ // Silent catch, lock couldn't be acquired. Some other process already generates the sitemap.
}