Is there a way to specify task concurrency program...
# ask-community
e
Is there a way to specify task concurrency programatically only within a single flow? Something like this
Copy code
@task(max_concurrency=100)  # concurrency limit defined in task decorator
def fn(i: int)
    print(i)

@flow
def main():
    map_range = list(range(1000))
    fn.map(map_range)
or this
Copy code
@task
def fn(i: int)
    print(i)

@flow
def main():
    map_range = list(range(1000))
    fn.map(map_range, max_concurrency=100)  # concurrency limit defined at task submission
In either case, we'd only want 100 instances of
fn
running at a given time. I know we can set concurrency limits in the cloud and task tags but this would be much nicer for us if possible!
n
hi @Erik Amundson - have you tried the context manager for concurrency?
e
Oh that looks perfect, thanks!