Skip to content
This repository was archived by the owner on Oct 4, 2023. It is now read-only.

Conversation

@brainysmurf
Copy link

backward behavior for python 3.5 - 3.10; no need for decorator if deprecated in python >= 3.11

@jayaddison
Copy link

jayaddison commented Jan 5, 2023

Please note: this library may not be actively maintained (see #17).

The changes in #11 offer a similar solution that should (I think?) also be Python 3.11 compatible. A tradeoff is that #11 avoids conditional assignment to __aexit__ (nice), but drops compatibility with some older Python versions as a side-effect (less nice).


__aexit__ = asyncio.coroutine(RateLimiter.__exit__)
# backward behavior for python 3.5 - 3.10; no need for decorator if deprecated in python > 3.11
__aexit__ = asyncio.coroutine(RateLimiter.__exit__) if hasattr(asyncio, 'coroutine') else RateLimiter.__exit__

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @brainysmurf - have you tested whether returning RateLimiter.__exit__ behaves as expected on Python 3.11? (it's declared using def, not async def, which is what has me wondering)

Copy link

@jondoescoding jondoescoding Apr 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't work as expected. Implemented the changes and when called I get:

name 'RateLimiter' is not defined

And the error points to "RateLimiter.exit"

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants