Future improvements to detecting when parallel mode is turned on could be made, as mentioned in the PR:
This is achieved by storing a queue in the env so the "write" workers can shove page names in there (sadly multiprocessing.Queue did not work as it apparently doesn't like the way the workers are created), and create_sitemap can then pop all that from the queue.
Anyway there's a bit of an issue here, probably not a huge one because sitemap is only invoked once per document (not hundreds of times per), but the multiprocessing queue is always created and possibly somewhat heavy (it's at least a separate process, plus whatever the proxies use to communicate with the subprocess), but while Builder has a parallel_ok flag that flag is only set during build(), which comes later than record_builder_type.
The only option I can see (aside from Sphinx being updated to resolve this earlier) is to copy the implementation details of parallel_ok in the extension and hope they don't change too much in the future, using that to decide between the seq and the parallel sitemap_links implementations, and that's gross.
Even hooking into one of the events between the reading and writing phase would not work: parallel_ok is actually set after env-check-consistency, and there doesn't seem to be any sequential event afterwards.
Summary of Changes
Notes
Huge shout-out to @xmo-odoo for https://github.com/jdillard/sphinx-sitemap/pull/29 (closed so couldn't merge).
Future improvements to detecting when parallel mode is turned on could be made, as mentioned in the PR:
Potentially better support from Sphinx outlined here: https://github.com/sphinx-doc/sphinx/issues/9480