<@ULVA73B9P> is there a way to set slot decay per ...
# ask-marvin
r
@Marvin is there a way to set slot decay per second programmatically for tag based concurrency limits?
m
thought for 85.7 seconds
Yes — programmatically, you can, but not via the older tag-limit helper API. For tag-based concurrency limits with slot decay, use the global concurrency limit API with a name like
tag:<your-tag>
. Example:
Copy code
python
from prefect import get_client

async def main():
    async with get_client() as client:
        await client.upsert_global_concurrency_limit_by_name(
            name="tag:my-tag",
            limit=10,
            slot_decay_per_second=1.5,
        )
A few important notes: -
slot_decay_per_second
is supported on global concurrency limits - tag-based limits are represented as global limits named
tag:<tag-name>
- the legacy method
create_concurrency_limit(tag, concurrency_limit)
does not expose
slot_decay_per_second
If you want to update an existing one:
Copy code
python
from prefect import get_client
from prefect.client.schemas.actions import GlobalConcurrencyLimitUpdate

async def main():
    async with get_client() as client:
        await client.update_global_concurrency_limit(
            name="tag:my-tag",
            concurrency_limit=GlobalConcurrencyLimitUpdate(
                slot_decay_per_second=2.0
            ),
        )
Conceptually: -
slot_decay_per_second = 0
-> standard concurrency limit -
slot_decay_per_second > 0
-> behaves like a rate limit, with slots decaying over time Relevant docs: - Global concurrency limits - Tag-based concurrency limits If you want, I can also show: - the sync client version - how to create this via the CLI - how this interacts with
@task(tags=[...])
usage