Skip to content

Commit

Permalink
Fix for an infinite loop logic error
Browse files Browse the repository at this point in the history
  • Loading branch information
sarperavci committed Jul 28, 2024
1 parent a0a422a commit 7c32df0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion func.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,22 @@ async def scan(self):
urlsFile = open(self.file, "r")
line = urlsFile.readline()

while line:
while line or self.pending or self.queue:
# create new tasks until the concurrency limit is reached
while len(self.pending) < self.concurrency:
if self.queue:
self.pending.append(asyncio.create_task(self.fetch(session, self.queue.pop(0))) )
else:
if not line:
break
payload_urls = self.createURLs(line.strip())
for payload_url in payload_urls:
if len(self.pending) < self.concurrency:
self.pending.append(asyncio.create_task(self.fetch(session, payload_url)))
else:
self.queue.append(payload_url)
line = urlsFile.readline()


# wait for at least one task to be completed
done, self.pending = await asyncio.wait(self.pending, return_when=asyncio.FIRST_COMPLETED)
Expand Down

0 comments on commit 7c32df0

Please sign in to comment.