RazerM / ratelimiter

Simple Python module providing rate limiting
Apache License 2.0
120 stars 29 forks source link

async w/ python 3.8 compatibility sans warnings #11

Open kapilt opened 4 years ago

kapilt commented 4 years ago

this closes #10 by using async syntax that doesn't trigger warnings.

this pr also removes from travis the versions of python3 that are end of life'd (3.3, 3.4) adds the newer ones (3.7, 3.8) and increments the version (post0->post1) for release to pypi.

smthfrmn commented 4 years ago

@RazerM can you look into this PR? I would like to have the update as well

daggy1234 commented 3 years ago

With 3.9 this would be great. I also have another issue with

https://mystb.in/RepresentativeBestApplications.apache

Would love a fix!

dhimmel commented 3 years ago

Thanks @kapilt for this update. Really hoping @RazerM sees this and can review/merge/release.

musicinmybrain commented 2 years ago

This seems to still work correctly in a development version of Python 3.11, in which the warned-about asyncio.coroutine decorator is actually removed.

gshuflin commented 2 years ago

Any movement on this issue? I see that https://github.com/pypa/pypi-support/issues/954 resuled in @gear4s being added as a maintainer by @RazerM . I'd like to use this library and it would help me out if this PR could get merged and a new PyPi release happen.

gear4s commented 2 years ago

Any movement on this issue? I see that https://github.com/pypa/pypi-support/issues/954 resuled in @gear4s being added as a maintainer by @RazerM . I'd like to use this library and it would help me out if this PR could get merged and a new PyPi release happen.

I will review and test this week, if all's good I will merge.

gshuflin commented 2 years ago

Any movement on this issue? I see that pypa/pypi-support#954 resuled in @gear4s being added as a maintainer by @RazerM . I'd like to use this library and it would help me out if this PR could get merged and a new PyPi release happen.

I will review and test this week, if all's good I will merge.

Awesome, looking forward to seeing this merged.

gshuflin commented 2 years ago

@gear4s have you had a chance to review and test this yet?

gear4s commented 2 years ago

@gear4s have you had a chance to review and test this yet?

Not yet - I've dedicated some time Saturday to do this. Work is beating me right now unfortunately

gshuflin commented 2 years ago

@gear4s did you ever have a chance to try this?

MilesCranmer commented 1 year ago

This is officially removed in Python 3.11 so dependent packages are now breaking. Please merge asap.

e.g., the entirety of snakemake: https://github.com/snakemake/snakemake is now breaking on Python 3.11.

cc @RazerM

MilesCranmer commented 1 year ago

FWIW @gshuflin I patched my local version with this PR and it works fine. But merging would be preferred so users don't encounter the same error.

dhimmel commented 1 year ago

@gear4s would be great to have this merged and released now that projects that use ratelimiter are stuck from upgrading to Python 3.11

uburuntu commented 1 year ago

Hello folks, it's kinda self-promoting, but since this repo was not updated since 2018 consider using https://github.com/uburuntu/throttler for async cases -- it has pretty close syntax and is a bit more efficient.

Migration for context managers

from ratelimiter import RateLimiter

rate_limiter = RateLimiter(max_calls=10, period=1)
with rate_limiter:
    do_something()

from throttler import Throttler

rate_limiter = Throttler(rate_limit=10, period=1)
async with rate_limiter:
    await do_something()

https://github.com/uburuntu/throttler#simple-example

Migration for decorators

from ratelimiter import RateLimiter

@RateLimiter(max_calls=10, period=1)
def do_something():
    pass

from throttler import throttle

@throttle(rate_limit=10, period=1)
async def do_something():
    pass

https://github.com/uburuntu/throttler#throttler-and-throttlersimultaneous

Migration example

https://github.com/snakemake/snakemake/pull/1958

RazerM commented 1 year ago

I use and recommend rush

RazerM commented 1 year ago

P.S. See https://github.com/RazerM/ratelimiter/issues/17