Python Forum

Full Version: Having Trouble With Threading
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This code isn't throwing errors, instead it's only giving me limited results based on "for i in range(20)" line. If I have it set as '20' it will only scrape 20 results, if I change it to '10' it will give me 10 etc.

It's ignoring the while loop requirements and I can't figure out why.

The script requires a test.csv file in working dir, here are some URLs: https://pastebin.com/TNYDBvTF

EXPAND CODE:
Suggest you take a gander at: https://pymotw.com/3/threading/

You'll probably be interested in: greenteapress.com/semaphores/LittleBookOfSemaphores.pdf
also as it shows how to communicate between threads
threads = []
for i in range(5):
    t = threading.Thread(target=worker, args=(i,))
    threads.append(t)
    t.start()
Does this code only generate the number of threads, or does it also automatically assign them to the project as well?

Am I having a problem with variables inside the main loop conflicting with the threads or is it a problem of not assigning threads properly or..? Where specifically am I not setting this up correctly?