Skip to content

trio.CapacityLimiter(math.inf) #618

Closed

Description

@acarl005

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?

Activity

  1. njsmith commented on Aug 22, 2018

    @njsmith
    Member

    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).)

  2. DjaPy commented on Nov 30, 2018

    @DjaPy

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

  3. njsmith commented on Nov 30, 2018

    @njsmith
    Member

    @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 :-).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions