Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concurrency limit UX enhancements: add strict mode #15297

Merged
merged 7 commits into from
Sep 10, 2024

Conversation

cicdw
Copy link
Member

@cicdw cicdw commented Sep 10, 2024

This PR deprecates create_if_missing which causes an ill-posed problem: creating a limit implicitly has no obvious default limit value.

Instead, the behavior we want is:

  • taking concurrency from a limit name that doesn't exist in the backend should be functionally equivalent to taking concurrency from a limit name that has a limit of None or from a limit that is "inactive" and therefore - at this instant - might as well not exist, i.e., it allows execution without creating any new object in the backend (and we log a WARNING to alert users)
  • for users who want stricter control, we have a new kwarg strict: bool that specifies whether to raise an error if the limit name doesn't exist in the backend; this defaults to False but can be set to True. Setting this to True is satisfying the need of "I really want to make sure I have full control over the circumstance in which this runs" and if the limit doesn't exist, we don't yet know those circumstances and so we prevent execution through a raised exception

I believe I need to revisit the docs for these utilities, but in the meantime wanted to get some eyes on the code.

@cicdw cicdw added the enhancement An improvement of an existing feature label Sep 10, 2024
@github-actions github-actions bot added the docs label Sep 10, 2024
Copy link

codspeed-hq bot commented Sep 10, 2024

CodSpeed Performance Report

Merging #15297 will not alter performance

Comparing create-if-missing-no-longer (d89faa1) with main (39a4f52)

Summary

✅ 3 untouched benchmarks

Copy link
Collaborator

@abrookins abrookins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks right to me! 👍

Copy link
Collaborator

@zzstoatzz zzstoatzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

async def test_concurrency_can_be_used_within_a_flow_strictly():
@task
async def resource_heavy():
async with concurrency("santa-clause", occupy=1, strict=True):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one heh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs enhancement An improvement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants