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

Add CapacityLimiter.UNLIMITED #587

Closed
wants to merge 2 commits into from

Conversation

njsmith
Copy link
Member

@njsmith njsmith commented Jul 30, 2018

Sometimes we have an API that wants a CapacityLimiter (like
run_sync_soon_in_worker_thread), and we want to have unlimited
capacity (for example, when putting a long-running blocking call into
a background thread, like WaitForMultipleObjects or waitpid). This can
be done by writing a little stub class that implements the
CapacityLimiter interface, but doing this all the time is annoying.
Here's a full-fledged version, available whenever you need it.

njsmith added 2 commits July 30, 2018 03:22
Sometimes we have an API that wants a CapacityLimiter (like
run_sync_soon_in_worker_thread), and we want to have unlimited
capacity (for example, when putting a long-running blocking call into
a background thread, like WaitForMultipleObjects or waitpid). This can
be done by writing a little stub class that implements the
CapacityLimiter interface, but doing this all the time is annoying.
Here's a full-fledged version, available whenever you need it.
@codecov
Copy link

codecov bot commented Jul 30, 2018

Codecov Report

Merging #587 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #587      +/-   ##
==========================================
+ Coverage   99.27%   99.27%   +<.01%     
==========================================
  Files          89       89              
  Lines       10640    10658      +18     
  Branches      747      747              
==========================================
+ Hits        10563    10581      +18     
  Misses         59       59              
  Partials       18       18
Impacted Files Coverage Δ
trio/_sync.py 100% <100%> (ø) ⬆️
trio/tests/test_sync.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6398e7a...a85afb6. Read the comment docs.

@sorcio
Copy link
Contributor

sorcio commented Jul 31, 2018

Worth trying to document why it might be needed? Or maybe mention one example? I can’t think of a short and effective explanation, and there are going to be more use cases than we can show; so maybe this is a hint that we shouldn’t and just leave it to users to understand whether this is what they need. On the other hand, this has the potential to cause some confusion and can be misused, e.g. as a shortcut not to think too hard about what limit to impose on thread spawning.

@njsmith
Copy link
Member Author

njsmith commented Aug 1, 2018

You know, that's an excellent question. I spent a while trying to document when you would use this, and couldn't figure out how to do it. I guess that means it's a bad idea.

Maybe we should consider allow CapacityLimiter(inf) as a more obscure version? I'm not sure. I'll reject this PR anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants