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

async w/ python 3.8 compatibility sans warnings #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
@@ -1,10 +1,10 @@
language: python
python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "3.6"
- "3.7"
- "3.8"
install: # No dependencies
script:
- pip install -U pip setuptools
Expand Down
2 changes: 1 addition & 1 deletion ratelimiter/__init__.py
Expand Up @@ -17,7 +17,7 @@
import sys

__author__ = 'Frazer McLean <frazer@frazermclean.co.uk>'
__version__ = '1.2.0.post0'
__version__ = '1.2.0.post1'
__license__ = 'Apache'
__description__ = 'Simple python rate limiting object'

Expand Down
5 changes: 3 additions & 2 deletions ratelimiter/_async.py
Expand Up @@ -19,7 +19,7 @@ async def __aenter__(self):
if self._alock is None:
self._init_async_lock()

with await self._alock:
async with self._alock:
# We want to ensure that no more than max_calls were run in the allowed
# period. For this, we store the last timestamps of each call and run
# the rate verification upon each __enter__ call.
Expand All @@ -32,4 +32,5 @@ async def __aenter__(self):
await asyncio.sleep(sleeptime)
return self

__aexit__ = asyncio.coroutine(RateLimiter.__exit__)
async def __aexit__(self, exc_type, exc_value, traceback):
return super(AsyncRateLimiter, self).__exit__(exc_type, exc_value, traceback)