You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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 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 :-).
Activity
njsmith commentedon Aug 22, 2018
Thanks!
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
CapacityLimitercode itself all works fine already withcapacity = 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 byCapacityLimiter(inf).)DjaPy commentedon Nov 30, 2018
Hi! Is it closed? I am a beginner, I want to understand how I can help
njsmith commentedon 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 :-).