Skip to content

Commit 87a817f

Browse files
authored
Merge pull request #72 from SharpBit/development
Development
2 parents 3135300 + e74dcfb commit 87a817f

4 files changed

Lines changed: 10 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## [4.0.5] - 7/27/20
5+
### Fixed
6+
- Removed the print statement on client initialization
7+
- Actually uses asyncio.Lock properly if the async client has the option `prevent_ratelimit=True`
8+
49

510
## [4.0.4] - 7/22/20
611
### Added

brawlstats/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
############
88

99

10-
__version__ = 'v4.0.4'
10+
__version__ = 'v4.0.5'
1111
__title__ = 'brawlstats'
1212
__license__ = 'MIT'
1313
__author__ = 'SharpBit'

brawlstats/core.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ def __init__(self, token, session=None, timeout=30, is_async=False, **options):
5959
)
6060
self.timeout = timeout
6161
self.prevent_ratelimit = options.get('prevent_ratelimit', False)
62+
if self.is_async and self.prevent_ratelimit:
63+
self.lock = asyncio.Lock(loop=self.loop)
6264
self.api = API(base_url=options.get('base_url'), version=1)
6365

6466
# Request/response headers
@@ -164,8 +166,8 @@ def _request(self, url):
164166
async def _aget_model(self, url, model, key=None):
165167
"""Method to turn the response data into a Model class for the async client."""
166168
if self.prevent_ratelimit:
167-
# Use asyncio.Lock() if prevent_ratelimit=True
168-
async with asyncio.Lock():
169+
# Use self.lock if prevent_ratelimit=True
170+
async with self.lock:
169171
data = await self._arequest(url)
170172
await asyncio.sleep(0.1)
171173
else:

brawlstats/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def __init__(self, base_url, version=1):
2727

2828
def set_brawlers(self, brawlers):
2929
self.CURRENT_BRAWLERS = {b['name'].lower(): int(b['id']) for b in brawlers}
30-
print(self.CURRENT_BRAWLERS)
3130

3231

3332
def bstag(tag):

0 commit comments

Comments
 (0)