Skip to content

Commit af84e84

Browse files
committed
fix asyncio.Lock issue and remove print statement
1 parent f32a84f commit af84e84

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

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)