Skip to content

Commit 25e5a2d

Browse files
committed
changes to leaky bucket
1 parent 42c4438 commit 25e5a2d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

ofscraper/classes/sessionmanager/download.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,14 @@ async def factoryasync(self, input):
103103
def chunk_with_limit(self, funct):
104104
async def wrapper(*args, **kwargs):
105105
async for chunk in funct(*args, **kwargs):
106-
size = len(chunk)
107-
await self.get_token(size)
106+
await self.get_token(chunk)
108107
yield chunk
109108
return wrapper
110109

111-
async def get_token(self, size):
112-
await self.leaky_bucket.acquire(size)
110+
async def get_token(self, chunk):
111+
if settings.get_download_limit() <= 0:
112+
return
113+
await self.leaky_bucket.acquire(chunk)
113114

114115

115116
class cdm_session(sessionManager.sessionManager):

0 commit comments

Comments
 (0)