From 59a0827c434706d62b89e16a220e4ae12e618858 Mon Sep 17 00:00:00 2001 From: Kapil Thangavelu Date: Tue, 18 Feb 2020 14:36:12 -0500 Subject: [PATCH] async w/ python 3.8 compatibility sans warnings --- .travis.yml | 4 ++-- ratelimiter/__init__.py | 2 +- ratelimiter/_async.py | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8f55cb1..9fbcb22 100644 --- a/.travis.yml +++ b/.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 diff --git a/ratelimiter/__init__.py b/ratelimiter/__init__.py index 94164c5..e43cde2 100644 --- a/ratelimiter/__init__.py +++ b/ratelimiter/__init__.py @@ -17,7 +17,7 @@ import sys __author__ = 'Frazer McLean ' -__version__ = '1.2.0.post0' +__version__ = '1.2.0.post1' __license__ = 'Apache' __description__ = 'Simple python rate limiting object' diff --git a/ratelimiter/_async.py b/ratelimiter/_async.py index feb80ad..04a9302 100644 --- a/ratelimiter/_async.py +++ b/ratelimiter/_async.py @@ -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. @@ -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)