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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import sys

__author__ = 'Frazer McLean <[email protected]>'
__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
Original file line number Diff line number Diff line change
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)