Skip to content

Instantly share code, notes, and snippets.

@AnderRV
Created August 11, 2021 15:11
Show Gist options
  • Save AnderRV/d44904ad54641828e66533e652a8e172 to your computer and use it in GitHub Desktop.
Save AnderRV/d44904ad54641828e66533e652a8e172 to your computer and use it in GitHub Desktop.
def queue_worker(i, q):
while True:
url = q.get()
if (len(visited) < max_visits and url not in visited):
crawl(url)
q.task_done()
q = queue.Queue()
num_workers = 4
for i in range(num_workers):
Thread(target=queue_worker, args=(i, q), daemon=True).start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment