bookmarks = self.bookmarks
pending = self.pending
- process = self.max_workers - len(pending)
- if bookmarks and (process > 0): # there's job and free workers
+ free_workers = self.max_workers - len(pending)
+ if bookmarks and (free_workers > 0): # there's job and free workers,
for href in bookmarks:
bookmark, parent, ft = bookmarks[href]
if ft is not None: # it's already pending
bookmarks[href] = [bookmark, parent, ft]
pending.add(ft)
+ free_workers -= 1
+ if free_workers == 0:
+ break
+
if pending:
done, pending = concurrent.futures.wait(
pending, self.timeout+1,