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

trio.CapacityLimiter(math.inf) #618

Closed
acarl005 opened this issue Aug 21, 2018 · 3 comments
Closed

trio.CapacityLimiter(math.inf) #618

acarl005 opened this issue Aug 21, 2018 · 3 comments

Comments

@acarl005
Copy link

Hello. Awesome concurrency library! I almost gave up on trying to use concurrency in Python. But Trio inspired me to stick with it.

I'm writing a library on top of Trio. I was hoping for an easy way to essentially "opt-out" of a capacity limit with a simple function argument. I tried something like this

limit = trio.CapacityLimiter(math.inf)

But this fails with the following error TypeError: total_tokens must be an int. It seems like it should be possible maybe. What do you think?

@njsmith
Copy link
Member

njsmith commented Aug 22, 2018

Awesome concurrency library! I almost gave up on trying to use concurrency in Python. But Trio inspired me to stick with it.

Thanks!

I was hoping for an easy way to essentially "opt-out" of a capacity limit with a simple function argument.

Can you share more about what your use case is? I know there are valid ones, but the last time this came up (#587) I got stuck because I couldn't figure out how to explain them in the docs. (Though, that PR did things in a less elegant way that required more explanation; if you read the comments you'll see we ended up thinking that CapacityLimiter(math.inf) might be better too :-).)

In any case, I agree this would be a good thing to support. Any interest in putting together a PR? The CapacityLimiter code itself all works fine already with capacity = inf, so the actual change would be pretty simple: just change the argument checking to require the value be int-or-math.inf. But it'd be nice to also have a test and a release note – see our contributing docs for details, or feel free to ask in chat. (And if you want to get a little fancier, there's some code in trio/_wait_for_object.py that could be replaced by CapacityLimiter(inf).)

@DjaPy
Copy link

DjaPy commented Nov 30, 2018

Hi! Is it closed? I am a beginner, I want to understand how I can help

@njsmith
Copy link
Member

njsmith commented Nov 30, 2018

@DjaPy Hello! You're right, this actually was fixed and the issue should have been closed, but sometimes these things get missed.... so, pointing that out is already a valuable contribution. You're off to a great start :-).

Unfortunately we're a bit short of "good first issues" right now, but there is this issue if you want to take a look: #251. It's a bit more complicated than CapacityLimiter(inf), but there are some detailed notes in the issue that might help? Definitely ask if you have any questions, low-level socket APIs can be confusing.

Otherwise, well... it depends on what you're interested in :-). I definitely recommend joining our gitter channel – that's where a lot of day-to-day discussion happens. There's a reply I wrote here to someone who asked about helping with documentation. If you can say some more about what your background is and what you're interested in, either here or in the gitter, then we can probably come up with some suggestions :-).

@njsmith njsmith closed this as completed Nov 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants