Skip to content

Commit

Permalink
changes to leaky bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
datawhores committed Sep 11, 2024
1 parent 42c4438 commit 25e5a2d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ofscraper/classes/sessionmanager/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,14 @@ async def factoryasync(self, input):
def chunk_with_limit(self, funct):
async def wrapper(*args, **kwargs):
async for chunk in funct(*args, **kwargs):
size = len(chunk)
await self.get_token(size)
await self.get_token(chunk)
yield chunk
return wrapper

async def get_token(self, size):
await self.leaky_bucket.acquire(size)
async def get_token(self, chunk):
if settings.get_download_limit() <= 0:
return
await self.leaky_bucket.acquire(chunk)


class cdm_session(sessionManager.sessionManager):
Expand Down

0 comments on commit 25e5a2d

Please sign in to comment.