Guido Stein
09/23/2022, 4:14 PMMason Menges
09/23/2022, 4:18 PMGuido Stein
09/23/2022, 4:23 PMMason Menges
09/23/2022, 4:47 PM@task(name="foo", tags=["concurrencytag"])
def foo():
print("Prefect_task)
you would then create a concurrency limit for that tag, you can do this through the python client or through the CLI,
CLI Example:
prefect concurrency-limit create concurrencytag 5
python example:
from prefect.client import get_client
async with get_client() as client:
c_limit = await client.create_concurrency_limit(tag="concurrencytag", concurrency_limit=5)
https://docs.prefect.io/concepts/tasks/#tags
https://docs.prefect.io/concepts/tasks/#python-clientGuido Stein
09/23/2022, 4:55 PMimport asyncio
from prefect import flow, task
from prefect.client import get_client
@task(tags=["small_instance"])
def task():
print("-----")
@flow()
def flow():
task.submit()
task.submit()
task.submit()
task.submit()
task.submit()
task.submit()
task.submit()
task.submit()
task.submit()
task.submit()
async def client_setup():
async with get_client() as client:
await client.create_concurrency_limit(tag="small_instance", concurrency_limit=2)
if __name__ == "__main__":
asyncio.run(client_setup())
flow()
Mason Menges
09/23/2022, 5:21 PM