"""Uniform queue + launch configuration for every Space.""" import os from .analytics import analytics_head from .theme import CSS, build_head def standard_launch(demo, config, jsonld_extra: dict | None = None, **launch_kwargs): """Apply the portfolio-standard queue limits and launch settings. Queue: bounded pending jobs and small concurrency so a burst of traffic (or abuse) cannot burn provider spend faster than the queue drains. AI events should additionally set concurrency_limit=1 on the event. """ demo.queue( max_size=int(os.environ.get("LF_QUEUE_MAX", "30")), default_concurrency_limit=int(os.environ.get("LF_CONCURRENCY", "2")), ) head = build_head(config, jsonld_extra) + analytics_head() demo.launch( css=CSS, head=head, footer_links=[], # no API/settings footer; events use api_name=False anyway **launch_kwargs, )