File size: 924 Bytes
bf3b56a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""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,
    )